I usually do this:
git init
git add .
git commit .
And then I realize that it's about to add my nbproject directory, which I want excluded/ignored. Sometimes, I even check in this directory. Had I added it to .git/info/exclude before running git add., everything works fine (it's excluded).
So then I modify .git/info/exclude and then it's too late. git no longer respects changes to .git/info/exclude.
So the questions are:
- How can I get git to take up the changes in the exclude file in the checkin? (I tried running git add . again, which doesn't help)
- Let's say I check in a directory (or file) that I want excluded. What is the least number of steps to get to the state I want (with the file excluded).
To remove a file that you have added but not committed, use a command like this:
This will remove the file from the index, but not touch the file on disk.
To remove a file (or files) from the most recent commit, use the above
git rm --cached
command followed bygit commit --amend
.