Git: global settings & ignore file
Git settings file
You can customize your Git environment by setting certain configuration variables. There are three levels of where these configuration variables are stored:
-
System /etc/gitconfig, applies default settings to every user of the computer.
To make changes to this file, use the
--systemoption with the git config command. -
User ~/.gitconfig or ~/.config/git/config, applies settings to a single user.
To make changes to this file, use the
--globaloption with the git config command. - Project YOUR-PROJECT-PATH/.git/config, applies settings to the project only. To make changes to this file, use the git config command.
If there are settings that conflict with each other, the project-level configurations overrides the user-level ones, and the user-level configurations overrides the system-level ones.
$ git config --global user.name "Alex"
$ git config --global user.email "email@example.com"
#configure your shell to add color to Git output with this command
$ git config --global color.ui true
#To see all your configuration settings
$ git config --list
How to create gitignore file
-
Set the path to the variable core.excludesfile
$ git config --global core.excludesfile ~/.gitignore #Find the file location $ git config --get core.excludesfile -
Create gitignore_global file in the root folder
$ cd ~/ $ touch .gitignore_global -
Add files to ignore
$ open -a TextEdit .gitignore_globalMost common files to ignore:
#Ignore Mac system files .DS_store #Ignore node_modules folder node_modules #Ignore files related to API keys .env #Ignore SASS config files .sass-cache