我在MAIN/repo.git
收到了一个回购邮件,我把它分给了FORK/repo.git
。我将这两个repos克隆到我的计算机上用于不同的目的。
使用Github for Windows,一个错误似乎已经将FORK/repo.git
转换为MAIN/repo.git
,就像我git remote show origin
一样,Fetch URL和Push URL设置为主回购。如何切换回来,以便本地计算机上的相应文件夹指向FORK/repo.git
,而不是MAIN/repo.git
?
答案 0 :(得分:79)
最简单的方法是在FORK
的本地克隆中使用命令行git remote
:
git remote rm origin
git remote add origin https://github.com/user/FORK.git
或者,在一个命令中,如GitHub article所示:
git remote set-url origin https://github.com/user/FORK.git
更好的做法是:
所以:
git remote rename origin upstream
git branch -avv # existing branches like master are linked to upstream/xxx
git remote add origin https://github.com/user/FORK.git
git checkout -b newFeatureBranch
每当您需要根据原始仓库的最新发展更新您的前叉时:
git checkout master
git pull # it pulls from upstream!
git checkout newFeatureBranch
git rebase master # safe if you are alone working on that branch
git push --force # ditto. It pushes to origin, which is your fork.