我在 github 上 fork 了一个公共(public)仓库来做一些更改。我创建了一个新分支并在那里实现了我的更改。现在我想从上游仓库获取新提交,但我只能将上游提交同步到我的主仓库而不是新分支。如何从上游同步到我的新分支而不是主分支?
最佳答案
How do I sync from upstream to my new branch instead of master?
您应该先同步 master
,然后在新更新的 master
之上重新设置您的分支。
git pull upstream master
git checkout yourBranch
git rebase master
git push -f origin yourBranch
假设你有一个名为“upstream
”的远程引用原始仓库的 url(你已经 fork )
有关“git remote add upstream
”命令示例,请参见“Pull new updates from original Github repository into forked Github repository”。
关于github - 如何在 fork 的 github 仓库中更新我的新分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22418370/