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 😉.