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

Trevor Miller
InstructorTrevor Miller

Share this video with your friends

Send Tweet
Published 6 years ago
Updated 3 years ago

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.

[00:00] 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.

[00:14] 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.

[00:33] 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.

Zhentian Wan
Zhentian Wan
~ 6 years ago

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

Kevin Pinny
Kevin Pinny
~ 5 years ago

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.

Trevor Miller
Trevor Millerinstructor
~ 5 years ago

You are welcome! Thank you for watching :)

Trevor Miller
Trevor Millerinstructor
~ 5 years ago

I'm glad :) Thank you.

Koleto
Koleto
~ 3 years ago

Perfekt course! Thank you!

It would be really helpful to have some general guidance on a project branching model and best practices on commit messages.

Massimo De
Massimo De
~ 3 years ago

Great course! I look forward for other git tricks

Omar Chajia
Omar Chajia
~ 3 years ago

Thank you, I needed this course to refresh my git knowledge ;) and clarify ambiguity.