Why .gitignore does not include a file with a prefix!

My .gitignore file looks like this:

build/ glucosia.xcodeproj/ !glucosia.xcodeproj/project.pbxproj core-plot/framework/build core-plot/framework/CorePlot-CocoaTouch.xcodeproj/ !core-plot/framework/CorePlot-CocoaTouch.xcodeproj/project.pbxproj .DS_Store Classes/.DS_Store 

Oddly, glucosia.xcodeproj/project.pbxproj not ignored, as you would expect.

But, core-plot/framework/CorePlot-CocoaTouch.xcodeproj/project.pbxproj is still ignored.

Any ideas?

Thank!

+7
git include gitignore
Feb 04 '10 at 2:34
source share
2 answers

As mentioned in the gitignore man page :

A gitignore indicates intentionally unverified files that git should ignore

If glucosia.xcodeproj/project.pbxproj (as suggested by Alan in the comments) is already being monitored, you need to remove it from the cache and then the gitingore directive will take effect.

 git rm --cached glucosia.xcodeproj/project.pbxproj 

If the file has already been committed, see this SO answer ( git commit --amend to remove it from the last commit)

+6
Feb 04 '10 at 5:17
source share

I had the same problem but a different solution. If you ignore the directory, but not the file inside it, it will not work. You must ignore the file directory.

This does not work:

 conf/ !conf/config.json.orig 

This will work:

 conf/* !conf/config.json.orig 
+5
Feb 12 '13 at 2:27
source share



All Articles