This lesson is for PRO members.

Unlock this lesson NOW!
Already subscribed? sign in

Practical Git: Remove all unnecessary git tracking with a global .gitignore file

0:57 Tools lesson by

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 .gitconfig.

Get the Code Now
click to level up

egghead.io comment guidelines

Avatar
egghead.io

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 .gitconfig.

Avatar
Zhentian

Thanks for the great course and great effort! Have learned many stuff.

Avatar
kefkef5

Thanks for lesson. It's the first one of many I wish to complete after getting the pro subscription. Quality resource for practical use of git, perfect.

Avatar
Trevor

You are welcome! Thank you for watching :)

In reply to kefkef5
Avatar
Trevor

I'm glad :) Thank you.

In reply to Zhentian

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.

HEY, QUICK QUESTION!
Joel's Head
Why are we asking?