我必须在一个文件夹中远程回购,写完git remote -v后我得到:
A https://github.com/A/repo.git (fetch)
A https://github.com/A/repo.git (push)
B https://github.com/B/repo.git (fetch)
B https://github.com/B/repo.git (push)
目前我在A的分公司大师,但我想换掉B的主分公司,我该怎么做?命令git checkout只允许我更改A的分支,但如果我想与B连接则不起作用。
答案 0 :(得分:2)
这是因为您在本地文件夹中使用git clone https://github.com/A/repo.git
,然后将远程origin
更改为A
并在本地文件夹中添加远程B
。因此所有本地分支都属于回购A.
如果您希望使用基于B/master
的本地分支,则可以使用git checkout -b master1 B/master
,然后根据需要替换master
。
如果您只想处理回购B,可以使用git clone https://github.com/B/repo.git
并将回购A
添加为远程。
答案 1 :(得分:1)
您可以通过在分支名称前指定遥控器的名称来结帐。
git checkout B/master
见。