So, after converting my repository to git and doing the first build, some build directories appeared 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 .gitignore , and since I did not want to enter 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/
Earlier, I assumed that the new .gitignore file contains the following 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, he 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
Yes. Why is my .gitignore ignored? I remember that in the last project, I could add it to the repository. I searched for quite a while and searched for something else that could lead to ignoring this file. .git/info/excludes has only commented lines, and all parent directories before / do not have .gitignore . Also git config core.excludesfile doesn't display anything.
Why?