質問するログイン新規登録

回答編集履歴

3

追記

2018/05/26 15:06

投稿

tkmtmkt
tkmtmkt

スコア1800

answer CHANGED
@@ -19,4 +19,67 @@
19
19
  $ rm -rf direcotry1/.git
20
20
  $ git add .
21
21
  $ git commit
22
+ ```
23
+
24
+ **追記2**
25
+
26
+ 以下のように確認作業を行ってみました。
27
+
28
+ ```sh
29
+ $ mkdir -p zzz/directory1
30
+
31
+ # directory1にgitリポジトリ作成してファイルを登録
32
+ $ cd zzz/directory1
33
+ $ git init
34
+ $ touch hoge fuga
35
+ $ git add .
36
+ $ git commit -m INIT
37
+
38
+ # zzzにgitリポジトリ作成してdirectory1を登録
39
+ $ cd ..
40
+ $ git init
41
+ $ git add .
42
+ warning: adding embedded git repository: direcotory1
43
+ ヒント: You've added another git repository inside your current repository.
44
+ ヒント: Clones of the outer repository will not contain the contents of
45
+ ヒント: the embedded repository and will not know how to obtain it.
46
+ ヒント: If you meant to add a submodule, use:
47
+ ヒント:
48
+ ヒント: git submodule add <url> direcotory1
49
+ ヒント:
50
+ ヒント: If you added this path by mistake, you can remove it from the
51
+ ヒント: index with:
52
+ ヒント:
53
+ ヒント: git rm --cached direcotory1
54
+ ヒント:
55
+ ヒント: See "git help submodule" for more information.
56
+
57
+ $ git commit -m INIT
58
+
59
+ # directory1のgitリポジトリを削除して状態確認
60
+ $ rm -rf direcotory1/.git
61
+ $ git status
62
+ ブランチ master
63
+ nothing to commit, working tree clean
64
+
65
+ # directory1内のファイルを登録してみる
66
+ $ git add direcotory1/*
67
+ fatal: Pathspec 'direcotory1/fuga' is in submodule 'direcotory1'
68
+ ```
69
+
70
+ directory1がサブモジュールとして登録されていると、directory1のgitリポジトリを削除してもdirectory1以下のファイルをリポジトリに追加できないようです。
71
+
72
+ 以下のようにdirectory1を一旦削除することで、directory1以下のファイルを追加することができました。
73
+
74
+ ```sh
75
+ $ git rm --cached direcotory1
76
+ $ git add .
77
+ $ git status
78
+ ブランチ master
79
+ コミット予定の変更点:
80
+ (use "git reset HEAD <file>..." to unstage)
81
+
82
+ deleted: direcotory1
83
+ new file: direcotory1/fuga
84
+ new file: direcotory1/hoge
22
85
  ```

2

追記

2018/05/26 15:06

投稿

tkmtmkt
tkmtmkt

スコア1800

answer CHANGED
@@ -8,4 +8,15 @@
8
8
 
9
9
  # gitの管理対象外になっているファイルを一覧表示する
10
10
  $ git status ignored
11
+ ```
12
+
13
+ **追記**
14
+
15
+ directory1がリポジトリになっているため、directory1の親ディレクトリのリポジトリからは管理対象とされないようです。
16
+ directory1がリポジトリになっているのが間違いなら、directory1内の.gitディレクトリを削除してください。
17
+
18
+ ```sh
19
+ $ rm -rf direcotry1/.git
20
+ $ git add .
21
+ $ git commit
11
22
  ```

1

誤記修正

2018/05/26 13:57

投稿

tkmtmkt
tkmtmkt

スコア1800

answer CHANGED
@@ -2,10 +2,10 @@
2
2
  なのでgithubにファイルが転送されていないのであれば、ローカルリポジトリにコミットされていないということです。
3
3
  ローカルリポジトリの内容を確認してみてください。
4
4
 
5
- '''sh
5
+ ```sh
6
6
  # リポジトリで管理しているファイルを一覧表示する
7
7
  $ git ls-files
8
8
 
9
9
  # gitの管理対象外になっているファイルを一覧表示する
10
10
  $ git status ignored
11
- '''
11
+ ```