Итак, после преобразования моего репозитория в git и выполнения первой сборки некоторые каталоги сборки появились в git status
:
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: build.xml
# modified: src/ant/common-tasks.xml
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# classes/
# doku/
# texdoku/
# tmp/
Итак, конечно, мне нужен .gitignore
, и, поскольку я не хотел снова вводить эти имена каталогов, я использовал эту команду:
git status -s | grep '?' | cut -b 4- > .gitignore
Так как git status -s
показал это
M build.xml
M src/ant/common-tasks.xml
?? classes/
?? doku/
?? texdoku/
?? tmp/
ранее я предполагал, что новый файл .gitignore
будет содержать следующие строки:
classes/
doku/
texdoku/
tmp/
Но тогда:
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: build.xml
# modified: src/ant/common-tasks.xml
#
no changes added to commit (use "git add" and/or "git commit -a")
Да, он игнорировал четыре каталога, но также и новый файл .gitignore
. Почему?
$ git add .gitignore
The following paths are ignored by one of your .gitignore files:
.gitignore
Use -f if you really want to add them.
fatal: no files added
Ха. Почему мой .gitignore
игнорируется? Я помню, что в прошлом проекте я мог добавить его в хранилище. Я долго искал и гуглил, что еще могло заставить этот файл игнорироваться - .git/info/excludes
имеет только закомментированные строки, а все родительские каталоги до /
не имеют .gitignore
. Также git config core.excludesfile
ничего не показывает.
Почему?