git 如何将主分支恢复到上游
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8134960/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to revert Master branch to upstream
提问by Gelin Luo
I have forked a git repository and setup upstream. I've made some changes in Master branch and committed and pushed to github.
我已经分叉了一个 git 存储库并在上游进行了设置。我在 Master 分支中做了一些更改并提交并推送到 github。
Now what should I do to abandon all my changes in Master branch and make it identical to the upstream's master branch?
现在我应该怎么做才能放弃我在 Master 分支中的所有更改并使其与上游的 master 分支相同?
回答by nickgrim
(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)
(我假设您现在想要忽略的更改在您的origin
遥控器上,您在您的master
分支上,并且您想恢复到upstream
遥控器的内容)
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