lihu129c 发表于 2018-1-13 09:33:03

Git 常用命令汇总

  

master : default development branch  
origin :
default upstream repository  
HEAD   : current branch and commit
  
HEAD
^: parent of HEAD  
HEAD
~4 : the great-great grandparent of HEAD  

  Alias
  

配置别名,想改成什么跟随自己的意愿即可。Git配置文件放在用户主目录下的一个隐藏文件.gitconfig中:”命令应该是:cat ~/.gitconfig  

  
git config --list //查看git配置
  git config
--global alias.st status //status 缩写成 st  
git config
--global alias.co checkout //checkout 缩写成 co  
git config
--global alias.br branch //branch 缩写成 br  
git config
--global alias.ci commit //commit 缩写成 ci  

  Git Config
  Git 配置文件分为三级,系统级(--system)、用户级(--global)和目录级(--local),三者的使用优先级以离目录 (repository)最近为原则,如果三者的配置不一样,则生效优先级目录级>用户级>系统级,可以通过 git config --help 查看更多内容。
  + 系统级配置存储在 /etc/gitconfig 文件中,可以使用 git config --system user.name “meng.chen" ,git config --sytem user.email "meng.chen@17zuoye.com" 来进行配置,该配置对系统上所有用户及他们所拥有的仓库都生效的配置值。
  + 用户级存储在每个用户的 ~/.gitconfig 中,可以使用 git config --global user.name "meng.chen" ,git config --global user.email "meng.chen@17zuoye.com"来进行配置,该配置对当前用户上所有的仓库有效。
  + 目录级存储在每个仓库下的 .git/config 中,可以使用 git config --local user.name "meng.chen" , git config --local user.email "meng.chen@17zuoye.com"来进行配置,只对当前仓库生效。
页: [1]
查看完整版本: Git 常用命令汇总