git常用配置(指令)

1、配置用户名和邮箱

  (1) 指令设置

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

   $ git config --global user.email johndoe@example.com

  (2) 修改配置文件.gitconfig

  

 

2、配置ssh key免密登录

  (1) 生成密钥

   $ ssh-keygen -t rsa -C '1046407517@qq.com'

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

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

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

   $ ssh -T git@github.com

   

   $ 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 、配置difftool可视化工具

  (1)difftool 配置  

  $ git config --global diff.tool bc4
  $ git config --global difftool.bc4.cmd "\"d:/install/Beyond Compare 4/BComp.exe\" \"$LOCAL\" \"$REMOTE\""

 最终.gitconfig将多出以下配置

  

    $ git difftool HEAD // 比较当前修改情况

6、配置mergetool可视化工具

     (1)mergeftool 配置
    $ git config --global merge.tool bc4
    $ git config --global mergetool.bc4.cmd "\"d:/install/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将多出以下配置

   

  $ git mergetool // 对比当前冲突文件

 

posted on 2018-10-21 16:42  daishengda  阅读(271)  评论(0编辑  收藏  举报