28

Possible Duplicates:
working with .git/info/exclude too late
.gitignore file not ignoring
git - removing a file from source control (but not from the source)

I have CVS/ in my both .gitignore and my .git/info/exclude files. But for some reason changes to any CVS folder are still tracked.

I'm tired of having to manually un-stage changes in these folders.

How do I make git stop tracking the CVS folders once it's decided to track them?

Community
  • 1
  • 1
dkinzer
  • 32,179
  • 12
  • 66
  • 85
  • or maybe of http://stackoverflow.com/questions/1139762/gitignore-file-not-ignoring ? – P Shved Nov 14 '10 at 17:45
  • or maybe this one: http://stackoverflow.com/questions/3296739/git-not-ignoring-certain-xcode-files-in-gitignore ? – P Shved Nov 14 '10 at 17:46
  • @Pavel: Yeah, this is one of those duplicates that's been asked in many ways but somehow still not enough for people to find it by searching. I'm never sure which one to point it back at. – Cascabel Nov 14 '10 at 18:30
  • 3
    And of course, putting this directory in both the gitignore and .git/info/exclude is redundant. You only need to use one or the other, and generally the gitignore is the right one. – Cascabel Nov 14 '10 at 18:31

1 Answers1

63

.gitignore only causes git to ignore untracked files. "CVS" is already tracked so you must first remove it from the repository with:

git rm -r --cached CVS

The --cached option causes git to leave the working copy of the file intact rather than removing it. Once done, the entry in .gitignore will prevent git from interacting with the CVS directory again.

How do I make git stop tracking the CVS folders once it's decided to track them?

Git will never "decide" to track content, it does only what you tell it to. At some point you manually added it to the index and then committed it to the repository.

Ondrej Slinták
  • 31,386
  • 20
  • 94
  • 126
user229044
  • 232,980
  • 40
  • 330
  • 338
  • 1
    @meager, ah *git rm --cached * is what I'm missing. – dkinzer Nov 14 '10 at 17:47
  • 1
    @DKinzer, .gitignore won't stop git from tracking a file it's already tracking. As meagar said, you also have to untrack it with 'rm'. You might also need the "-r" flag for a directory and the "-f" flag to ignore changes that aren't checked in. – Heatsink Nov 14 '10 at 17:47
  • 1
    @meager, "At some point you manually added it to the index and then committed it to the repository." -- not really, it came in for the ride via an git-svn import. But I guess I must have been tracking them when I was using SVN, and just didn't realize it. – dkinzer Nov 14 '10 at 18:22
  • Why only the first sub folder has ignored, but the sub folder of the sub folder not ignored? – Gank Oct 23 '15 at 02:20