This has been something that has plagued me for years and I’ve never sat down to properly fix it.
Instead, I’ve just added
.gitignore files probably over one hundred times by over.
Anyway, the git documentation mentions the existence of a variable called
If you don’t set it, and
$XDG_CONFIG_HOME isn’t overridden, you can add global ignores to
Let’s see this in action. First we’ll make a brand new Git repository and add a
> mkdir sports > cd sports > git init Initialized empty Git repository in /Users/marcus/Code/sports/.git/ > touch .DS_Store > git status On branch main No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) .DS_Store nothing added to commit but untracked files present (use "git add" to track)
Ah yes, the perpetual hell but let’s try out our new trick.
> echo ".DS_Store" >> ~/.config/git/ignore > git status On branch main No commits yet nothing to commit (create/copy files and use "git add" to track)