0

Description of the problem

I have config.codekit listed inside my project's .gitignore file, but changes to config.codekit are still tracked by git.

Steps to reproduce the problem

  1. create a new project, initialize git, and add the project to CodeKit
  2. make the first commit
  3. add config.codekit to the project's .gitignore file
  4. do $ git status and see that .gitignore is listed under Changes not staged for commit, as expected
  5. (optionally commit again here, but the problem persists even without committing)
  6. affect config.codekit by opening CodeKit and changing project settings, such as adding a directory to Skipped Items & Paths. alternatively you can manually edit or even delete config.codekit
  7. Open config.codekit (if it hasn't been deleted) and mentally note the changes made
  8. do $ git status and see that, along with .gitignore, config.codekit is listed under Changes not staged for commit.

Expected result

config.codekit should not be listed anywhere when checking git status.

chharvey
  • 8,580
  • 9
  • 56
  • 95
  • During your steps to reproduce the problem, does `config.codekit` ever get committed at all, or is it never a part of the repo aside from a line in the `.gitignore`? – Maximillian Laumeister Aug 18 '15 at 18:56
  • Looks like config.codekit is already in git index. If so, you can remove it from git (git rm config.codekit), then commit it, then the file will not track. – isqua Aug 18 '15 at 18:56
  • @MaximillianLaumeister `config.codekit` has already been in the commit history. I've edited my question to clarify. thanks. – chharvey Aug 18 '15 at 18:58
  • @MaximillianLaumeister — I'm confused, I thought changes to files listed in .gitignore (even if those files are already tracked by git) were still ignored. – chharvey Aug 18 '15 at 19:01
  • @chharvey That is indeed not the case, and I think it's the heart of your question. `.gitignore` only prevents untracked files from being added, it does not prevent files that have already been added from continuing to be tracked. – Maximillian Laumeister Aug 18 '15 at 19:02

1 Answers1

2

Try git rm --cached <file>

Amit Dalal
  • 642
  • 8
  • 20