如何恢复主分支到上游 [英] How to revert Master branch to upstream
问题描述
我分叉了一个git仓库,并在上游安装。我在Master分支做了一些改动,并提交给github。
I have forked a git repository and setup upstream. I've made some changes in Master branch and committed and pushed to github.
现在我该怎么做才能放弃Master分支中的所有更改并使其与上游的主分支?
Now what should I do to abandon all my changes in Master branch and make it identical to the upstream's master branch?
推荐答案
(我假设您现在要忽略的更改是在 origin
remote,你在你的 master
分支上,并且你想要恢复到上游的内容
(I'm assuming that the changes that you now want to ignore are at your origin
remote, you're on your master
branch, and you want to revert to the contents of the upstream
remote)
首先,将您的工作副本重置为上游主数据:
Firstly, reset your working copy to the upstream master:
git remote update
# the double hyphen ensures that upstream/master is
# considered as a revision and not confused as a path
git reset --hard upstream/master --
然后将这个新分支头推到您的原始存储库,它不会是一个快进:
Then push this new branch-head to your origin repository, ignoring the fact that it won't be a fast-forward:
git push origin +master
这篇关于如何恢复主分支到上游的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!