0

I have a project with a .gitignore file that looks like:

*.2007
*.~*
*.identcache*
__history/*
*.drc
*.dproj.local
*.groupproj.local
*.exe
*.map
*.tvsconfig
LibrarySupport/*
z*/*
*ModelSupport*
*.zip
.DS_Store
*.mp4
*.orig
*.cbk
*.dcu

Yet it continues to track .dcu files in my project.

What am I doing wrong here?

croceldon
  • 4,511
  • 11
  • 57
  • 92
  • possible duplicate of [how to ignore files in git?](http://stackoverflow.com/questions/4308610/how-to-ignore-files-in-git) – Cascabel Feb 01 '12 at 20:23
  • Also http://stackoverflow.com/questions/6030530/git-ignore-not-working-in-a-directory http://stackoverflow.com/questions/3220629/make-git-ignore-files http://stackoverflow.com/questions/3833561/why-git-doesnt-ignore-my-specified-file http://stackoverflow.com/questions/7142181/git-how-do-i-ignore-a-directory-that-is-already-in-the-repository-without-dele http://stackoverflow.com/questions/1143796/git-remove-a-file-from-the-repository-without-deleting-it-from-the-local-filesy – Cascabel Feb 01 '12 at 20:25

1 Answers1

3

If the file was already tracked before the .gitignore was added (or updated) it will continue to have changes tracked.

Try something like find . -name "*.dcu" -exec git rm --cached {} \; to get rid of the ones that exist in the repository already.

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
  • 3
    -1: `rm --cached`, unless you actually want to delete the files. (Be really careful giving people commands that cause irreversible loss of data.) – Cascabel Feb 01 '12 at 20:23
  • @Jefromi: That's not irreversible; git rm should only work if the file is already tracked, *and* there have been no changes made. – Arafangion Feb 01 '12 at 22:20
  • @jefromi, that is good advice, but this particular command does not cause irreversible loss. The data is still available from git. – William Pursell Feb 01 '12 at 22:20
  • Okay, maybe not irreversible. Bad side effect nontheless, though - and it could be especially annoying if they've been modified since they were last committed. – Cascabel Feb 01 '12 at 22:24
  • 1
    I can't confirm, but I believe that * needs to be escaped, or *.dcu quoted. – johnny Feb 02 '12 at 04:46
  • @johnny It doesn't *have* to be but if a file with a `.dcu` extension exists in the current dir it will be expanded by the shell. A backslash or quotes would eliminate this behavior (and I have updated the answer as a result). – Jake Wharton Feb 02 '12 at 05:38
  • Thanks, @JakeWharton, that was exactly what I suspected, plus the explanation. – johnny Feb 02 '12 at 11:46