git常用配置(指令)

1、配置用户名和邮箱

  (1) 指令设置

   $ git config --global user.name "username"

   $ git config --global user.email [email protected]

  (2) 修改配置文件.gitconfig

  

2、配置ssh key免密登录

  (1) 生成密钥

   $ ssh-keygen -t rsa -C '[email protected]'

  (2) 在github添加自己生成的公钥

   点击头像=>Settings=>SSH and GPG keys=>New SSH Key=>保存即可

       (3) 测试添加的key是否成功

   $ ssh -T [email protected]

   

   $ git remote -v    查看远程git-url

4、配置默认编辑器notepad++

  $ git config --global core.editor notepad++
  $ git config --global core.editor "'D:\install\Notepad++\notepad++.exe' -multiInst -notabbar -nosession -noPlugin '$*'"

  最终.gitconfig多以下配置

  

5、配置mergetool可视化工具

     (1)mergeftool 配置
    git config --global merge.tool bc4
    git config --global mergetool.bc4.cmd "\"c:/program files (x86)/beyond compare 4/bcomp.exe\" \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\""
    git config --global mergetool.bc4.trustExitCode true

     (2)让git mergetool不再生成备份文件(*.orig)
    git config --global mergetool.keepBackup false

  .gitconfig将多出以下配置

   

猜你喜欢

转载自www.cnblogs.com/daishengda/p/9824711.html