6

Global Git Ignore

 1 year ago
source link: https://dcordero.me/posts/global_git_ignore.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

David Cordero

Global Git Ignore

Published on 05 Apr 2023

It is a well-known feature that every project in Git allows defining a list of files that should be ignored and not tracked. This is a common practice and is as simple as defining a file called .gitignore in the base path of your repo. The content of this file is simply the list of files or file patterns to be ignored.

However, because this file is part of a specific project, it is still a common issue to end up pushing unwanted files by mistake. Pushing the famous .DS_Store file is a good example of this.

The good news is that we can easily solve this issue by defining a global .gitignore file that applies to all our projects.

To create a global .gitignore file, we need to create a file listing the files that we want to ignore globally. For example, we can use the file ~/.gitignore_global with the following content:

*~
.DS_Store

After creating the global .gitignore file, we need to configure Git, using the file ~/.gitconfig, for it to know that this file should be use as a global git ignore.

[core]
    excludesfile = ~/.gitignore_global

You can find a working example of this configuration in my dotFiles repo.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK