thoughts.sort()

How to set a global gitignore file

September 07, 2020

Tags: git

Add system files to your global .gitignore file instead of the one in your project.

Having random dotfiles referenced across your projects’ ignore files is bad practice, since they’ve got nothing to do with the project and everything to do with the environment.

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .env/
        .vscode/

nothing added to commit but untracked files present (use "git add" to track)
$ echo ".env/" >> ~/.gitignore
$ echo ".vscode/" >> ~/.gitignore
$ echo ".DS_Store" >> ~/.gitignore
$ git config --global core.excludesfile ~/.gitignore

$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean