1.配置不同git仓库命名实现
# 添加远程仓库(可添加多个) git remote add github git@github.com/anzhihe/youprojectname.git git remote add coding git@coding.net/anzhihe/youprojectname.git # 向不同仓库推送 git push github master git push coding master
2.更改git仓库配置实现
# 进入项目目录,执行用户配置命令 ➜ git config user.name "anzhihe" ➜ git config user.email "anzhihe@chegva.com" 为所有项目设置默认的用户名和邮箱,加--global即可 # 直接配置.git/config文件,添加不同用户信息,如下 [user] name = anzhihe email = anzhihe@chegva.com # 查看git项目配置信息 ➜ git config --list
3.配置~/.ssh/config文件实现
➜ ~ cat ~/.ssh/config Host * User anzhihe ServerAliveInterval 30 ControlMaster auto ControlPath /tmp/ssh-%r@%h:%p ControlPersist yes StrictHostKeyChecking=no Compression=yes ForwardAgent=yes Host github HostName github.com User anzhihe@chegva.com PreferredAuthentications publickey IdentityFile /home/anzhihe/.ssh/id_rsa Host code.chegva.com HostName chegva.com User anxiaohe Port 22 IdentityFile /home/anxiaohe/.ssh/id_rsa Host ssh.github.com Hostname ssh.github.com User anzhihe IdentityFile ~/.ssh/id_rsa Port 443 ProxyCommand socat - PROXY:proxy.chegva.com:%h:%p,proxyport=1080
如果已经克隆过项目了,需要修改项目中.git/config文件
[remote "origin"] url = git@code.chegva.com:git/Session.git fetch = +refs/heads/*:refs/remotes/origin/*
检验配置是否正确
$ ssh -vT git@code.chegva.com
参考: