[未整理]GIT/GITHUB/GERRIT多账户

当前目录中项目的git配置文件为.git/config

从gerrit/github/gitlab下载后,要修改.git/config,增加[user]段落

同时如果有使用gerrit,要增加gitreview.username选项:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = ssh://10114292@gerrit.zte.com.cn:29418/paas/bdt/bdt-center
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

[user]
        name = 10114292
        email = geng.liang5@zte.com.cn

[remote "gerrit"]
        url = ssh://10114292@gerrit.zte.com.cn:29418/paas/bdt/bdt-center.git
    fetch = +refs/heads/*:refs/remotes/gerrit/*
[gitreview]
    username = 10114292

对gerrit,还需要创建和编辑.gitreview文件

[gerrit]
host=gerrit.zte.com.cn
port=29418
project=paas/bdt/bdt-center.git
username=10114292

 

 

 

 

 

修改前

root@a2440:~# git config -l
user.name=10114292
user.email=10114292@zte.com.cn
push.default=simple


root@a2440:/home/dockerws# cat ~/.gitconfig 
[user]
    name = 10114292
    email = 10114292@zte.com.cn
[push]
    default = simple


去除全局配置

git config --global --unset user.name
git config --global --unset user.email


root@a2440:/home/dockerws# cat ~/.gitconfig 
[user]
[push]
    default = simple

也可用命令:
git config --global push.default simple


创建github账号的key

root@a2440:~# ssh-keygen -C "hawkkingokey@163.com" -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa_github
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa_github.
Your public key has been saved in /root/.ssh/id_rsa_github.pub.
The key fingerprint is:
87:a6:59:18:4b:c3:ff:eb:29:85:42:f1:c6:cc:cb:5f hawkkingokey@163.com
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|     ..          |
|      =*         |
|     ..**.       |
|     .ooSo.      |
|      .=+o. E    |
|      o. o..     |
|        . .o     |
|         o+      |
+-----------------+

创建~/.ssh/config文件:

Host eta
HostName 10.62.100.147
Port 8000
User 10114292
IdentityFile ~/.ssh/id_rsa


Host zte
HostName gitlab.zte.com.cn
User 10114292
IdentityFile ~/.ssh/id_rsa

Host github
HostName github.com
User hawkkingokey
IdentityFile ~/.ssh/id_rsa_github

github项目管理

root@a2440:/home/gitworkspace# mkdir gittest
root@a2440:/home/gitworkspace# cd gittest/
root@a2440:/home/gitworkspace/gittest# ls
root@a2440:/home/gitworkspace/gittest# git init
Initialized empty Git repository in /home/gitworkspace/gittest/.git/
root@a2440:/home/gitworkspace/gittest# git config user.name hawkkingokey
root@a2440:/home/gitworkspace/gittest# git config user.email hawkkingokey@163.com
代理设置(可以跳过,使用系统的代理设置)
root@a2440:/home/gitworkspace/gittest# git config http.proxy proxysh.zte.com.cn:80
root@a2440:/home/gitworkspace/gittest# git config https.proxy proxysh.zte.com.cn:80
root@a2440:/home/gitworkspace/gittest# git config http.sslverify false
git config core.gitproxy proxysh.zte.com.cn:80

使用https协议clone github代码
root@a2440:/home/gitworkspace/gittest# git clone https://github.com/wiztools/rest-client.git

老项目的目录如果要提交代码,也需要配置用户和邮箱
root@a2440:/home/gitworkspace/eta-sh# git config user.name 10114292
root@a2440:/home/gitworkspace/eta-sh# git config user.email 10114292@zte.com.cn

转载于:https://my.oschina.net/u/1858599/blog/708167

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值