我有一个回复电话,MAIN/repo.git
我已经把它分叉了FORK/repo.git
.我将这两个repos克隆到我的计算机上用于不同的目的.
使用Github for Windows,一个bug似乎已经切换FORK/repo.git
到MAIN/repo.git
,就像我一样git remote show origin
,Fetch URL和Push URL被设置为主repo.如何切换回来,以便我本地机器上的相应文件夹指向FORK/repo.git
,而不是MAIN/repo.git
?
Von*_*onC 84
最简单的方法是git remote
在您的本地克隆中使用命令行FORK
:
git remote rm origin
git remote add origin https://github.com/user/FORK.git
Run Code Online (Sandbox Code Playgroud)
或者,在一个命令中,如此GitHub文章中所示:
git remote set-url origin https://github.com/user/FORK.git
Run Code Online (Sandbox Code Playgroud)
更好的做法是:
所以:
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
Run Code Online (Sandbox Code Playgroud)
每当你需要根据原始回购的最新进展更新你的fork:
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.
Run Code Online (Sandbox Code Playgroud)