最简单的方法是git remote
在您的本地克隆中使用命令行FORK
:
git remote rm origin
git remote add origin https://github.com/user/FORK.git
或者,在一个命令中,如这篇GitHub 文章所示:
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.