If you regularly use code editors, GUI tools or other programs that automatically create files and folders, you may want to set up a global
.gitignore file which will apply to every repo on your machine. In this lesson, we show how to do that by creating a
.gitignore_global file with the dotfiles in our
~/ root directory, and then link it to all git repos using our global
If we know that every gitrepo on a machine is going to need to ignore a specific file or folder type, we can create a global .gitignore. To do this, let's first change directories to where we store our doc files, which in this case will be my user root.
Next, let's create a .gitignore global file. The name of this file is up to you. This is the convention that GitHub suggests. Let's open this file in our code editor and we can add any file or folder patterns that we would like to ignore in all of our gitrepos. Let's save and close this file and return to our command line.
We can run gitconfig -- global core.excludesfile. The path of where we've placed our global gitignore file. When we create new gitrepos, and files or folders that match our patterns in our gitignore are created, Git can ignore them from anywhere on our system.