Config

Configuration Level

Git projects can be configured at the system, user or project level.

  • system level - changes are made for all users on the computer
  • user level - changes are made only for the current user
  • project level  - changes are made per project
#SYSTEM LEVEL CONFIGURATION
 git config --system  {REST_OF_COMMAND}
#USER LEVEL CONFIGURATION
 git config --global  {REST OF COMMAND}
#PROJECT LEVEL CONFIGURATION
 git config           {REST OF COMMAND}

Set Git Author

Set the user and email for git project

 git config --global user.email "[email protected]"
 git config --global user.name "Your Name"

Set Git UI Colors

Color code the output using the default colors
Allowed Color: normal, black, red, green, yellow, blue, magenta, cyan, or white.
For the styling we can choose from the following "bold, dim, ul, blink, and reverse".
If two colors are given the first is the foreground and the second is the background. see stackoverflow for color detail.

#automatically use the default color scheme.
git config --global color.ui true

#we can also only color specific
#color.branch, color.diff, color.interactive, color.status
#ex.
#set the foreground to blue and the text to black.
$ git config --global color.diff.meta "blue black bold"

#manually set the color for each state
git config color.status.changed yellow  #modified but not staged
git config color.status.added green     #staged but not committed
git config color.status.untracked red   #untracked files

View Configurations

 #list all the current configuration
 git config --list
 #list specific configuration
 git config user.name
 git config user.email

Set Code Editor

Set the editor to be used for editing git related task such as adding commit messages. By default, Git uses whatever you’ve set as your default text editor ($VISUAL or $EDITOR) or else falls back to the vi editor to create and edit your commit and tag messages. To change that default to something else, you can use the core.editor

#git config --global core.editor [YOUR_EDITOR_NAME]
git config --global core.editor vim

Configuration File

The configuration files are located at different locations based on the configuration level. System Wide Config

  • linux  -  /etc/gitconfig
  • windows  -  Prgram Files\Git\etc\gitconfig

User Level

  • linux/mac -     ~/.gitconfig
  • $HOME\.gitconfig

Project Level

  • .git/config
Cookbook Category: 
Git