.gitignore失效的解决方法

转载自http://foreverdo.diandian.com/post/2012-09-20/40038034798

How to make .gitignore works?

Just got the answer from the IRC channel.

Running command:

    git rm -r --cached .(delete all cached file)

This removes everything from the index, then just run:

    git add .

Commit it:

    git commit -m ".gitignore is now working"
 
  

To untrack a file that has already been added/initialized to your repository, ie stop tracking the file but not delete it from your system use:

git rm --cached filename  (delete single cached file)

 

Yes - .gitignore system only ignores files not currently under version control from git. I.e. if you've already added a file called test.txt using git-add, then adding test.txt to .gitignore will still cause changes to test.txt to be tracked. You would have to git-rm test.txt first, commit that change. Only then will changes to test.txt be ignored.

 

another problem I had was I placed an inline comment.

 tmp/*   # ignore my tmp folder (this doesn't work)

this works

 # ignore my tmp foldertmp/

你可能感兴趣的:(github)