Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
git_config [2019/02/18 09:20] – [Overview] rpjdaygit_config [2019/02/18 09:57] (current) – [Configuration sections and keys] rpjday
Line 36: Line 36:
 </code> </code>
  
-===== Configuration sections and keys =====+===== Basic configuration examples =====
  
-Format of ''<section>.<key>'':+Configuration settings of the form ''<section>''.''<key>'':
  
-  * ''user.name'' +<code> 
-  * ''user.email'' +$ git config --global user.name "Robert P. J. Day" 
-  * ''core.editor'' +$ git config --global user.email "rpjday@crashcourse.ca"
-  * ''color.ui'' +
-  * ''format.pretty''+
  
-Format of ''<section>.<subsection>.<key>'':+$ git config --global core.editor vim 
 +$ git config --global core.whitespace "fix,-indent-with-non-tab,trailing-space,cr-at-eol"
  
-  * ''remote.origin.url'' +$ git config --global branch.current "yellow bold" 
-  * ''branch.master.merge''+$ git config --global branch.local "green bold" 
 +$ git config --global branch.remote "cyan bold"
  
-Sections and keys are //not// case-sensitive, while (weirdly) those middle subsections //are//:+$ git config --global color.ui false
  
-  * ''user.name'' +$ git config --global alias.br branch 
-  * ''UsEr.nAmE'' +$ git config --global alias.cm commit 
-  * ''REMOTE.origin.URL'' +$ git config --global alias.cl clone 
-  ''BrAnCh.master.meRGE''+</code> 
 + 
 +All of the above (based on specifying ''%%--%%global'') end up in your (INI-style) personal ''~/.gitconfig'' file with the form: 
 + 
 +<code> 
 +[user] 
 + email = rpjday@crashcourse.ca 
 + name = Robert PJ. Day 
 +[color] 
 + ui = false 
 +</code> 
 + 
 +and so on. 
 + 
 +To delete a configuration setting, add ''%%--%%unset''
 + 
 +<code> 
 +$ git config --global --unset alias.br 
 +</code>
  
 ===== Three levels of configuration ===== ===== Three levels of configuration =====
 +
 +In order of processing (later settings override earlier ones):
 +
 +  * system (''/etc/gitconfig'')
 +  * global (''~/.gitconfig'')
 +  * local (''.git/config'') [associated with the repo itself]
  
 ==== /etc/gitconfig (--system) ==== ==== /etc/gitconfig (--system) ====
Line 72: Line 96:
 ==== ~/.gitconfig (--global) ==== ==== ~/.gitconfig (--global) ====
  
-Per-user (it would have killed them to call it ''%%--%%user''?):+Per-user:
  
 <code> <code>
Line 112: Line 136:
 </code> </code>
  
-===== Setting your configuration ===== +NOTE: If you don't specify which of the three levels you want, the operation defaults to ''%%--%%local'', which will fail if you are not inside a working tree, and is probably not what you want, anyway.
- +
-==== Global configuration ==== +
- +
-Setting globally (in personal ''~/.gitconfig''): +
- +
-<code> +
-$ git config --global user.name "Robert P. J. Day" +
-$ git config --global user.email "rpjday@crashcourse.ca" +
-$ git config --global color.ui false +
-</code> +
- +
-==== Local configuration ==== +
- +
-Setting locally (in repo'''.git/config''): +
- +
-<code> +
-$ git config [--local] gui.wmstate normal   (the default mode) +
-</code>+
  
 ===== Listing config settings ===== ===== Listing config settings =====
Line 181: Line 187:
 ===== Overriding configuration settings ===== ===== Overriding configuration settings =====
  
-==== One-time config override with -c ==== 
  
-<code> 
-$ git -c user.name="Keyser Soze" <command>... 
-</code> 
  
 ==== Environment variables ==== ==== Environment variables ====
  
-As an example, ''git commit'' searches for the editor to use when entering the commit message:+Most Git commands support environment variables for overriding configuration settings. As an example, ''git commit'' searches for the editor to use when entering the commit message:
  
   * ''GIT_EDITOR'' environment variable   * ''GIT_EDITOR'' environment variable
Line 207: Line 209:
 $ man git $ man git
 </code> </code>
 +
 +==== One-time config override with -c ====
 +
 +If you need a one-time-only override of some config setting, most Git commands support the "-c" option:
 +
 +<code>
 +$ git -c user.name="Keyser Soze" <some command>...
 +</code>
 +===== Sections and subsections =====
 +
 +Format of ''<section>.<key>'':
 +
 +  * ''user.name''
 +  * ''user.email''
 +  * ''core.editor''
 +  * ''color.ui''
 +  * ''format.pretty''
 +
 +Format of ''<section>.<subsection>.<key>'':
 +
 +  * ''remote.origin.url''
 +  * ''branch.master.merge''
 +
 +Sections and keys are //not// case-sensitive, while (weirdly) those middle subsections //are//:
 +
 +  * ''user.name''
 +  * ''UsEr.nAmE''
 +  * ''REMOTE.origin.URL''
 +  * ''BrAnCh.master.meRGE''
  • git_config.1550481658.txt.gz
  • Last modified: 2019/02/18 09:20
  • by rpjday