Values in .gitignore_global ignored after changed

I accidentally added a common directory to .gitignore_global that I actually need to be able to commit. When I removed it from .gitignore_global I still can't get it to show up so I can commit it to my repositories.

This is affecting several repositories that this same dir is under.

I tried restarting SourceTree after making the change and saving the file, but no luck.

The dir is not ignored in any other .gitignore files and I double checked to be sure.

Mac OS 10.9

3 answers

1 accepted

Git will not let you go back and change what happened in the past.  Now that you have modified .gitignore to remove a file from being listed there,  that change only applies to the future, not to the past.  If the file you are concerned about is named foo.txt,  than you need to to "git add foo.txt" and then git commit -m 'foo.txt no longer part of .gitignore. Will be tracked from now on'.

    And it goes without saying, that if the file is not physically in your working directly, then you need to put it there yourself manually, so that you can do that "git add foo.txt" in the paragraph above.

I tried doing "git add storage -f" for the "storage" directory which is what was ignored. This caused all .gitignore files in all the sub-directories to be ignored, which is not what I want since some files shouldn't be added. If I just do "git add storage" I get the error "The following paths are ignored by one of your .gitignore files: app/storage" I've checked all my .gitignore files all the way up (there are only two) and neither has that entry for storage.

Maybe git itself has the global gitignore cached somewhere. Did you try rebooting?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,207 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you