Skip to content

Instantly share code, notes, and snippets.

@lmllrjr
Created February 8, 2023 12:42
Show Gist options
  • Save lmllrjr/5a4a4b2c95d6941df1e9d70953264ef4 to your computer and use it in GitHub Desktop.
Save lmllrjr/5a4a4b2c95d6941df1e9d70953264ef4 to your computer and use it in GitHub Desktop.
Setup a global `.gitignore` file

To prevent adding/commiting/pushing unwanted files, like for example .DS_Store, one should have a global gitignore file. Here is how you can set it up:

  • Use the following command to set up a global gitignore:

    git config --global core.excludesFile '~/.gitignore_global'

    The command above will write/create the following lines in the existing ~/.gitconfig:

    [core]
      excludesfile = ~/.gitignore_global
  • Afterwards create the "global" gitignore file at your home folder:

    touch ~/.gitignore_global
  • In the end populate that file with some filenames/directories you really dislike and do not want to commit/push ever ...and at least add .DS_Store in there 😉.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment