Git是什么?

  Git是目前世界上最先进的分布式版本控制系统。

       它没有中央服务器的,每个人的电脑就是一个完整的版本库,这样,工作的时候就不需要联网了,因为版本都是在自己的电脑上。既然每个人的电脑都有一个完整的版本库,那多个人如何协作呢?比如说自己在电脑上改了文件A,其他人也在电脑上改了文件A,这时,你们两之间只需把各自的修改推送给对方,就可以互相看到对方的修改了

git 有三种级别的配置文件,分别是: 
       project level:对应 projectDir/.git/config 文件;设置命令为在项目根目录下执行 git config (no --global or --system). 
      global level: 对应 ~/.gitconfig 文件;设置命令为任意目录下执行 git config --global;只有在做了 git config --global 设置后 ~/.gitconfig 文件才会存在。 
      system level: 对应 /etc/gitconfig 文件;设置命令为任意目录下执行 git config --system (如果当前不是root用户,注意权限问题);只有在做了 git config --system 设置后 /etc/gitconfig 文件才会存在。

三种级别配置文件之间的关系是 project level 重写 global level,global level 重写 system level,参见: 

http://www.codinginahurry.com/2011/02/05/three-levels-of-git-config/ 
所以,添加 --global 参数的 git config 修改的是全局的 git 配置文件 ~/.gitconfig,也就是说会对所有的项目有效的;如果只是想修改特定某个项目的 git 配置项,则在该项目根目录下执行不带 --global 参数的 git config 即可,此时修改的是该项目下的 .git/config 文件

常用命令: 
一般说的repo,都指的是current HEAD commit。 
config:

      1. # 查看当前的git配置项;如果出现了某个key(如user.name)重复出现的现象,是因为你在不同 level 的git配置文件中都设置了该key,前面的会被后面的重写掉,所以不用担心  
      2. $ git config --list  
      3. $ git config --global user.name "John Doe"   
      4. $ git config --global user.email johndoe@example.com  
      5. # 项目中文件权限的变更不作为文件被更改的判断依据 
      6. $ git config --global core.filemode false  
      7. #编辑当前项目对应的git配置文件 projectDir/.git/config  
      8. $ git config -e  
      9. #编辑 global level 的git配置文件 ~/.gitconfig  
      10. $ git config --global -e  
      11. #编辑 system level 的git配置文件 /etc/gitconfig  
      12. $ git config --system -e  
      13. $ git config --global core.editor "vim"  
      14. $ git config --global merge.tool vimdiff  
      15. # 配置 git push 的默认策略 (matching 和 simple 的区别 参见 http://stackoverflow.com/a/13148313/1635855)  
      16. $ git config --global push.default simple  
      17. $ git config --list