There are things one never wants to store away into a version control system such as Git. In the source code world, we’re talking about junk like temporary editor files, .DS_Store, and user specific files. In a team environment, it’s essential to not burden others with things that only you care about.
So one typically creates a .gitignore file. Usually that takes care of everything you need. However, there is that awkward moment where you want to add something to the .gitignore file, but it only pertains to you. Worse, what if it only pertains to you in a specific project?
There’s a great article titled Ignoring files which outlines just what you need. As it says in the article, you can use the “explicit repository excludes” approach. You just have to change the .git/info/exclude
in your Git repository root. For example, when I do a git status, it shows:
Untracked files:
(use “git add <file>…” to include in what will be committed)switch_to_1_2_3.sh
switch_to_develop.sh
If you change the .git/info/exclude
in your Git repository root, it takes care of it.
This is a great solution if you are not worried about losing some simple .gitignore rules and they are project specific. In my case, I simply added the following to the mostly empty exclude file that is already there:
switch_to_1_2_3.sh
switch_to_develop.sh
Done! It’s that easy.
Given that I work at a place (CARFAX) which prides itself on knowledge sharing and software developer growth, I decided to blog this here for all to enjoy. So, enjoy!