私についてのいくつかの質問を読んだ後.gitignore
、私の質問に答えることができる人は誰も見つかりませんでした:
すべてのフォルダなど、特定の末尾のすべてのファイルを無視するには、.gitignoreに何を追加する必要が
ありますか*.txt
。
.gitignore
トップレベルのファイルは1つだけにしたいです。
私はいくつかのことを試しましたが、どれもうまくいきませんでした。
これは私がテストしたものです(.gitignore
以前にリポジトリに追加され、他のファイルは追加されませんでした):
$ ls
abc.txt content
$ ls content/
abc.txt def.other def.txt
$ echo "" > .gitignore
$ git status --ignored --untracked-files=all
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .gitignore
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# abc.txt
# content/abc.txt
# content/def.other
# content/def.txt
no changes added to commit (use "git add" and/or "git commit -a")
これは予想どおりです。.gitignoreが空であるため、すべてのファイルが表示されます。
$ echo "*.txt" > .gitignore
$ git status --ignored --untracked-files=all
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: .gitignore
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# content/def.other
# Ignored files:
# (use "git add -f <file>..." to include in what will be committed)
#
# abc.txt
no changes added to commit (use "git add" and/or "git commit -a")
content/abc.txtファイルとcontent/def.txtファイルがリストに表示されないのはなぜですか?
$ git clean -n
Would not remove content/
ここにも現れると思いました。
$ echo "" > .gitignore
$ git clean -n
Would remove abc.txt
Would not remove content/
$ cd content
$ git clean -n -x
Would remove def.other
$ git clean -n -x
Would remove abc.txt
Would remove def.other
Would remove def.txt
ファイルcontent/abc.txtとcontent/def.txtがで表示されているが、で表示されてclean -n -x
いない場合clean -n
、それらは無視されると思います。しかし、なぜ彼らはに現れないのgit status --ignored --untracked-files=all
ですか?