So, after converting my repository to git and doing the first build, some build directories showed up in 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/
So, of course I need a .gitignore
, and since I didn't want to type these directory-names again, I used this command:
git status -s | grep '?' | cut -b 4- > .gitignore
Since git status -s
showed this
M build.xml
M src/ant/common-tasks.xml
?? classes/
?? doku/
?? texdoku/
?? tmp/
before, I assumed the new .gitignore
file to contain these lines:
classes/
doku/
texdoku/
tmp/
But then:
$ 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")
Yes, it ignored the four directories, but also the new .gitignore
file. Why?
$ 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
Huh. Why is my .gitignore
ignored? I remember that in the last project I could add it to the repository. I searched quite a time, and googled what else could cause this file to be ignored - .git/info/excludes
has only commented lines, and all parent-directories up to /
have no .gitignore
. Also git config core.excludesfile
shows nothing.
Why?