Missing File - A .gitconfig Mystery

TIL: Using a .gitconfig file to manage when secrets and other files are not checked into source control is a wonderful thing.  That is, until you try to figure out why a file is NOT included in source control.  One command and one .gitignore file  can really help you and trip you up. This is the story of forgetting that I set a global ignore file and what I learned tracking down the issue.  

Apparently the tale started in September 2017 with the creation of a .gitignore_global file in my ~/ user folder. It seems I had done this originally to add a local.settings.json in order to globally exclude these often sensitive configuration files from being checked in to source control.

Well, time passes, you get a little older and you forget what else you might have put in there.  I was also apparently using developer.settings.json and excluded that file name globally as well at some point in time. That is the back story.

Fast forward several years, I recently wanted to check in developer.settings.json and could not.  It kept appearing as excluded in VS Code (as a dimmed file name in my color scheme).  

In researching where this might be excluded, I came across the following command.

git config --list --show-scope --show-origin

The above command outputs the following.  

Output of git config --list --show-scope --show-origin

The core.excludesfile entry led me back to the .gitignore_global file and I found the issue.  Apparently I was a bit aggressive in my exclusions... Problem solved!

Turns out the command is a relatively new capability, or at least a refinement, in Git v2.26.  See git 2.26.0 is here! for more details.  HTH someone else. I am sure I will be referring back to this in the future.

Tweet Post Update Email

My name is Pete Skelly. I write this blog. I am the VP of Technology at ThreeWill, LLC in Alpharetta, GA.

comments powered by Disqus