- bitbucket account
- 本地git配置不同的bitbucket账号仓库
- 方法:
- 步骤
- 在本地C:/user/.ssh/中,生成公钥和私钥,新建config文件
- 在Bitbucket账号内,添加SSH公钥
- 在./ssh目录下测试ssh-key是否连通:
- 在local repository下,进行git配置
- git clone怎么办
| bitbucket account | |
|---|---|
| local | local@email.com |
| company | company@email.com |
在~./ssh/下各自生成不同的密钥和公钥,再对应到各自账号的bitbucket/settings/SSH keys下。
在不同的本地仓库下配置git config和 remote url。
步骤 在本地C:/user/.ssh/中,生成公钥和私钥,新建config文件- 进入:/user/.ssh/,open git bash
- 生成公钥和私钥:
ssh-keygen -t rsa -f id_rsa_local一路回车,
ssh-keygen -t rsa -f id_rsa_company一路回车
3. 将私钥配置到本地git上
ssh-agent bash
ssh-add id_rsa_local
ssh-add id_rsa_company
ssh-add -l查看私钥添加结果
4. 创建并配置config文件(非文本文件)
.ssh目录下创建config文件,git通过该文件确定对应的私钥和公钥
config文件内容:
# local Host local HostName bitbucket.org IdentityFile ~/.ssh/id_rsa_local # company Host company HostName bitbucket.org IdentityFile ~/.ssh/id_rsa_company在Bitbucket账号内,添加SSH公钥
1. 进入bitbucket 的local账号,进入Personal Setting-> SSH Keys-> Add SSH Keys,添加复制id_rsa_local.pub公钥内容; 2. 进入bitbucket 的company 账号,进入Personal Setting-> SSH Keys-> Add SSH Keys,添加复制id_rsa_company.pub公钥内容;在./ssh目录下测试ssh-key是否连通:
ssh -T git@local authenticated via ssh key. You can use git to connect to Bitbucket. Shell access is disabled ssh -T git@company authenticated via ssh key. You can use git to connect to Bitbucket. Shell access is disabled
此时公钥和私钥都配置正确了。
在local repository下,进行git配置- 进入D:/local repository/,open git bash
- git config user.name "local"
- git config user.email "lcoal@email.com"
- git config --list 查看配置是否更新
- git remote rm origin 删除之前的remote
- git remote -v 查看
- git remote add origin git@local:username/repo.git
如果要git clone的话,需要使用SSH的方式clone。
SSH 的链接格式为:
git clone git@bitbucket.org:username/repo.git
修改为:
git clone git@local:username/repo.git
或
git clone git@company:username/repo.git



