Tech notes

Javascript, HTML, CSS

Dec 16, 2019 | git productivity

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:

  1. System /etc/gitconfig, applies default settings to every user of the computer. To make changes to this file, use the --system option with the git config command.
  2. User ~/.gitconfig or ~/.config/git/config, applies settings to a single user. To make changes to this file, use the --global option with the git config command.
  3. 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

  1. Set the path to the variable core.excludesfile

    
    	$ git config --global core.excludesfile ~/.gitignore
    
    	#Find the file location
    	$ git config --get core.excludesfile
    
    
  2. Create gitignore_global file in the root folder

    
    	$ cd ~/
    	$ touch .gitignore_global
    
    
  3. Add files to ignore

    	$ open -a TextEdit .gitignore_global

    Most 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
    
    


Back to blog