Use git config

We know config configuration is meant, then git git config command is to do some configuration. The configuration usually write in the configuration file inside, then where git configuration file in it? Interactive look, ask everyone.
Git you know where to put the configuration file is? There are several configuration files git it? Yes, you clever little look up information to know slightly, git which a total of three profiles, the first is: warehouse level configuration file
Member: The file is located in the current repository path .git /, .gitconfig file name, set the configuration where only the current content repository effective depot-level configuration file is as follows:
 
The second is the global-level configuration file: win7 following path in the user directory, a personal PC, for example, the path is: C: \ Users \ zuoyu.ht, the file name .gitconfig
Global-level configuration file as follows:
 
 
Finally, system-wide configuration files: the installation directory of local git to the left of the Royal git installation path, for example: D: \ Program Files \ Git \ etc, the file name: gitconfig, reads as follows:
 
Three from the comparison chart, we can see that the name of some configuration items is the same, such as "core", in git, with each configuration name is also called "section",
"Section" below each row corresponds to a key and a value. Note that: system-wide configuration file is different from the other two profiles, because he was less
A point, so use vim open when it is not highlighted. "Core" of this section has, then it will eventually call git configuration in which each profile
File it? This must be the order of a.
2. How does the configuration file into effect
For git, the configuration file
The weights are warehouse> Global> System. Git will use this series of configuration files to store your preferences defined, it first looks for / etc / gitconfig file (system level), the
File containing configuration values ​​for all users and they have a warehouse on the system are in force. The next place Git looks for each user's ~ / .gitconfig file (global level). At last
Git looks for each library defined by the user in the configuration file in the Git directory .git / config (warehouse level), the value of this document is only valid for the current owned warehouse. Set forth above three
Layer is arranged from general to specific layers forward, if there is a conflict defined value, whichever defined in the rear layer, for example: .git / config and / etc / gitconfig contest,
.git / config victory. Although you can manually edit the configuration files directly, but run the git config command generally easier. Here we take a look as
What use git config command to edit the configuration file at all levels.
   3. Check the configuration file with the git config command
Command parameter -list, abbreviated -l
Format: git config [-local | -global | -system] -l
View the warehouse level config, that is, .git / .config, command: git config -local -l
View global level config, that is, C: \ Users \ zuoyu.ht \ .gitconfig, command: git config -global -l
View system-level config, ie D: \ Program Files \ Git \ etc \ gitconfig, command: git config -system -l
Check the configuration currently in effect, the command: git config -l, this time to show the configuration information after the final three profiles calculated as shown below:
   4. Use the git config command to edit the configuration file
What editor of the English word, yes, edit
Command parameters -edit, short -e
Format: git config [-local | -global | -system] -e
View the warehouse level config, that is, .git / .config, command: git config -local -e, and -list parameter is different, git config -e is the default configuration file editing warehouse stage.
View global level config, that is, C: \ Users \ zuoyu.ht \ .gitconfig, command: git config -global -e
View system-level config, ie D: \ Program Files \ Git \ etc \ gitconfig, command: git config -system -e
   When executing this command, git will open the configuration file with the configuration file settings editor.
      5. Add a configuration item
-Add parameters
Format: git config [-local | -global | -system] -add section.key value (the default is to add the local configuration)
Note add back section, key, value a Less otherwise be added. For example, we perform: git config -add cat.name tom
And then view the local configuration:
 
Note the addition of a configuration without assignment git config -add cat.age, or just add a section, git config -add cat1, will not succeed.
6. Obtain a configuration item
Sometimes, we do not need to see all of the configuration values, but to see the value of a configuration item, how to do it?
-Get command parameters
Format: git config [-local | -global | -system] -get section.key (default configuration is to obtain local content)
We first write to the global configuration in a cat.name = Tomcat configuration items, and then what is the git config -get cat.name get a look
 
The result is local in cat.name = Tom, so git config -get section.key equivalent to git config -local -get section.key
If the acquisition value of a key section that does not exist, does not return any value
If the acquisition value section of a key that does not exist, it will error
 
  7. Delete a configuration item
Command parameters -unset
格式:git config [–local|–global|–system] –unset section.key
I believe that with the use of the first two basic commands, you know that you learned how to use the change to, we try to delete the local configuration cat.name
 
 
root@SKY-20191009SLB /cygdrive/e/telpo/syhuo.net/syhuo.net
# git config --local --list
core.repositoryformatversion=0
core.filemode=false
core.bare=false
core.logallrefupdates=true
core.symlinks=false
core.ignorecase=true
remote.origin.url=http://liuchao:[email protected]:9090/r/syhuo.net.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
credential.helper=store

root@SKY-20191009SLB /cygdrive/e/telpo/syhuo.net/syhuo.net # git config --global --list user.name=hnhycnlc888 [email protected] root@SKY-20191009SLB /cygdrive/e/telpo/syhuo.net/syhuo.net

 

Guess you like

Origin www.cnblogs.com/hnhycnlc888/p/11735979.html