一台电脑同时使用GitLab和GitHub仓库
2017-04-05 09:24
375 查看
到不同的国家要用不同的货币。同一台电脑 想要同时使用GitHub和GitLab,那么到GitHub家自然要用GitHub的钥匙才能开门,到GitLab家就要用GitLab家的钥匙。那么要做的有两点:
注意:
Enter file in which to save the key (/Users/kingboy/.ssh/id_rsa): /Users/kingboy/.ssh/github_id_rsa
输入的是钥匙的位置和名称。github和gitlab是不同的。
完成后会在~/.ssh/目录下生成以下文件:
github_id_rsa
github_id_rsa.pub
gitlab_id_rsa
gitlab_id_rsa.pub
将两个pub文件分别配置到github和gitlab的sshkey中
执行以下命令:
config内容如下:(HostName根据自己实际需求来定)
接下来在两个目录下新建或者clone项目开发即可.
1. 用Git生成两把钥匙;
#GitHub的钥匙 # kingboy @ KingBoydeMacBook-Pro in ~/.ssh [7:50:33] ➜ ssh-keygen -t rsa -C "kingboy@163.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/kingboy/.ssh/id_rsa): /Users/kingboy/.ssh/github_id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/kingboy/.ssh/github_id_rsa. Your public key has been saved in /Users/kingboy/.ssh/github_id_rsa.pub. The key fingerprint is: SHA256:h6UQw+e68ncp5sidqbBpRk3WKUR04VgdJpeIlqWnfrc kingboyworld@163.com The key's randomart image is: +---[RSA 2048]----+ | +=+*++o | | *Oo+o | | o++o.. | | ++++ | | +.oS . | | ..o . | | .. ... .. | | +=.+++o. | | ooo===oE | +----[SHA256]-----+
#gitlab ➜ ssh-keygen -t rsa -C "personal@company.com" Generating public/private rsa key pair. Enter file in which to save the key (/Users/kingboy/.ssh/id_rsa): /Users/kingboy/.ssh/gitlab_id_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/kingboy/.ssh/gitlab_id_rsa. Your public key has been saved in /Users/kingboy/.ssh/gitlab_id_rsa.pub. The key fingerprint is: SHA256:h6UQw+e68ncp5sidqbBpRk3WKUR04VgdJpeIlqWnfrc personal@company.com The key's randomart image is: +---[RSA 2048]----+ | +=+*++o | | *Oo+o | | o++o.. | | ++++ | | +.oS . | | ..o . | | .. ... .. | | +=.+++o. | | ooo===oE | +----[SHA256]-----+
注意:
Enter file in which to save the key (/Users/kingboy/.ssh/id_rsa): /Users/kingboy/.ssh/github_id_rsa
输入的是钥匙的位置和名称。github和gitlab是不同的。
完成后会在~/.ssh/目录下生成以下文件:
github_id_rsa
github_id_rsa.pub
gitlab_id_rsa
gitlab_id_rsa.pub
将两个pub文件分别配置到github和gitlab的sshkey中
2. 编写config文件,告诉本地git到不同的国家带不同的钥匙。
例如:github地址:github.com gitlab地址:gitlab.max.com
执行以下命令:
cd ~/.ssh vim config
config内容如下:(HostName根据自己实际需求来定)
#gitlab Host gitlab HostName gitlab.*.com IdentityFile ~/.ssh/gitlab_id_rsa #github Host github HostName github.com IdentityFile ~/.ssh/github_id_rsa
3. 配置仓库
例如:github工作仓库:~/workspace/github gitlab工作仓库:~/workspace/gitlab
#gitlab cd ~/workspace/gitlab git init git config --global user.name 'personal' git config --global user.email 'personal@company.com'
#github cd ~/workspace/github git init git config --local user.name 'kingboy' git config --local user.email 'kingboy@163.com'
接下来在两个目录下新建或者clone项目开发即可.
相关文章推荐
- 一台电脑上的git同时使用两个github账户
- 同一台电脑需要同时配置github和gitlab
- 同一台电脑上使用gitlab和github
- 一台电脑上同时使用两个github账户
- 一台电脑上的git同时使用两个github账户
- [转]一台电脑上的git同时使用两个github账户
- 在一台电脑上同时关联GitLab和GitHub
- 如何在同一台电脑使用不同的账号提交到同一个github仓库
- 一台电脑实现push不同仓库到两个github账号
- 一台电脑绑定两个git帐号(GitHub和GitLab)
- 如何在同一台电脑上使用两个github,一个往coding推,一个往github推,亲测有效哦
- 一台主机 两台显示器 就可以两个用户同时使用电脑
- 一台电脑实现push不同仓库到两个github账号
- 如何在同一台电脑上使用两个github账户
- 如何使用GitHub管理自己的项目同时使用gitlab管理公司的项目
- 一台电脑同时配置github私人账户和公司账户
- 如何在同一台电脑上使用两个github账户
- 在一台电脑上使用两个github账号
- 如何在同一台电脑上使用两个github账户
- 一台可以让32个用户同时、独立使用办公软件的电脑