Git

Gitignore a file globally

Ignoring a file globally is easy

Table of Contents
  1. The trick

Sometimes you might want to exclude a file on every git repository that you have, but you don't want to add that file to .gitignore. In my case, I've been using two files on my projects, a TODO and a NOTES.

Both of these files are just plain text files. The TODO I'm using to keep all the todos for that project. I find that it works best to have the TODO file on the project folder so I can quickly open and tick off the things that I have been working on than to go to the browser and use trello or another task manager.

The notes file was something that David Poindexter suggested that I should do. On his projects, he adds a NOTES file where he keeps track of all the things he has worked on, what worked, what didn't and that will help in the future when you have to come back to an old project.

The trick

This was a trick that Jacob Tomlinson shared with me when I added my TODO file to opsdroid .gitignore file. He said that I should add this file on my global .gitignore and pointed me to this Stack Overflow answer - Global Git Ignore

shell
1git config --global core.excludesfile '~/.gitignore'

This command will allow you to tell git where your .gitignore file is and the --global flag will add this file as global, so every single project that you start will look into that file and ignore anything inside it.

The cool thing is that the project's gitignore will also work, so you can have your own file and a project's gitignore working together.

I hope you enjoy this little trick and that it proves useful for you.

Webmentions

0 Like 0 Comment

You might also like these

Learn how to deal with a git conflict, why it happens and how to fix conflicts directly from your editor.

Read More
Git

Git: Merge Conflicts

Git: Merge Conflicts

Learn about git rebase, pulling changes from a master branch and how to keep your git history under control.

Read More
Git

Git: Commit history

Git: Commit history

Deleting files doesn't mean deleted permanently, learn how to turn back time and recover deleted files.

Read More
Git

Git: Recover Deleted Files

Git: Recover Deleted Files

It can be a bit painful to write full git commands over and over again, so I've created a few aliases to shorten the number of keys I have to press while doing git stuff.

Read More
Git

Git Aliases

Git Aliases