[Git configuration tips] 01. gitconfig

Source: Internet
Author: User
Git has a tool called gitconfig that allows you to get and set configuration variables. These variables can control the appearance and operations of Git. 1. storage location of the configuration file these variables can be stored in three different locations: 1. etcgitconfig file: contains all users and libraries of the system. If you pass the Parameter options

Git has a tool called git config that allows you to get and set configuration variables. These variables can control the appearance and operations of Git. 1. storage location of the configuration file these variables can be stored in three different locations: 1./etc/gitconfig file: contains all users and libraries of the system. If you pass the Parameter options

Git has a tool called git config that allows you to get and set configuration variables. These variables can control the appearance and operations of Git.

1. storage location of configuration files

These variables can be stored in three different locations:

1./etc/gitconfig file: contains values applicable to all users and libraries of the system. If you pass the parameter option '-- system' to git config, it will explicitly read and write the file.

2 .~ /. Gitconfig file: specific to your user. You can enable Git to read or write this specific file by passing the -- global option.

3. the config file (that is,. git/config) in the git Directory: No matter what library you are currently using, it points to this single library. Each level overrides the value of the previous level. Therefore, the value in. git/config overwrites the same value in/etc/gitconfig.

2. Configure your username and password

After installing Git, you must first set your user name and e-mail address. This is very important because this information is used every time a Git commit is made. It is always embedded in your submission:

  

$ git config --global user.name "wirelessqa"$ git config --global user.email wirelessqa.me@gmail.com

Reapply this setting. You only need to perform this setting once. If you pass the -- global option, Git will always use this information to process all your operations in the system. If you want to use different names or e-mail addresses in a specific project, you can run the command in the project instead of the -- global option.

3. Configure your Compiler

Your ID has been set. You can configure your default text editor. Git will use this text editor when you need to enter some messages. By default, Git uses the default editor of your system, which may be vi or vim. If you want to use a different text editor, such as Emacs, you can do the following:

  

$ git config --global core.editor emacs
4. Configure your comparison tool

Another useful option you may need to configure is the default comparison tool, which is used to solve conflicts during merge. For example, if you want to use vimdiff:

  

$ git config --global merge.tool vimdiff

Git can use kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff as effective merge tools. You can also set a custom tool;

5. Check your configuration

If you want to check your settings, you can use the git config -- list command to list all the settings that Git can find here:

  

$ git config --list  user.name=wirelessqa  user.email=wirelessqa.me@gmail.com  color.status=auto  color.branch=auto  color.interactive=auto  color.diff=auto  ...

You may see a keyword appears multiple times, because Git uses different files (for example,/etc/gitconfig and ~ /. Gitconfig) read the same keyword. In this case, Git uses the last value for each unique keyword.

You can also view the current value of a specific keyword that Git deems, and use the following command git config {key }:

  $ git config user.name  wirelessqa

6. Get help

If you need help when using Git, you can obtain the help information on the manual page (manpage) of any git command in three ways:

 

 $ git help 
 
   $ git 
  
    --help $ man git-
   
  
 

For example, you can run the following command to obtain help on the config command manual page:

 $ git help config

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.