When .gitgnore is not enough

| Comments

I’m currently working on a project with multiple dev teams contributing together to a few different repositories, combined into one system. And we’re using git, of course. We have very strict branching model. It takes weeks to see your work merged to master, even for the simplest things. The project is quite big and sometimes I’m using pieces of code that nobody else’s using, even when working on the same module. And here’s where the .gitignore file is not enough.

.gitignore

You probably know .gitgnore file. It uses matching patterns to define files that Git should intentionally ignore. If you’re a git user, you should know enough about this file.

If you feel you repeat yourself in your .gitignore files among the projects, it’s a good idea to configure it in a different place.

~/.gitconfig

Let me paste the explanation from the official git documentation here: Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig

But it’s not solving my problem. I’m using some project-specific files that may require git tracking in different repos on my machine. At the same time, I’m the only one who is using them in the current project in development. Tracking them is a mess, adding them to .gitignore makes no sense at all - no one should actually know about these files at all. In the edge case - adding them to .gitignore can affect the others in case of someone would want to add these files to the repo, sic!. How to live?

$GIT_DIR/info/exclude

Tada! Easy! the $GIT_DIR/info/exclude file is a local list of ignored files which is not affecting the repo at all. Let’s say it’s a kind of your private, untrackable .gitignore file per repo. Awesome!

Comments