使用 git,如何将本地部署分支重置为 origin 的版本?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10663766/
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
With git, how do I reset the local deployment branch to origin's version?
提问by Tom
I've got a local branch called deployment
. This branch is also on origin
. How do I reset the local deployment branch to the state of origin
's deployment branch?
我有一个名为deployment
. 这个分支也在origin
。如何将本地部署分支重置为 的部署分支的状态origin
?
Something like the following:
类似于以下内容:
git fetch origin
git reset --hard origin/deployment
Would that be possible?
那可能吗?
采纳答案by Mark Longair
That's correct, but be careful - git reset --hard
throws away alluncommitted changes, i.e. those just in your working tree or the index (staging area). Also, just make sure that you really are on the deployment
branch with git checkout deployment
, since git reset
always changes the position of the current branch, i.e. the one that HEAD
points to.
这是正确的,但要小心 -git reset --hard
丢弃所有未提交的更改,即那些只是在您的工作树或索引(暂存区)中的更改。另外,只需确保您确实在deployment
带有的分支上git checkout deployment
,因为git reset
总是会更改当前分支的位置,即HEAD
指向的位置。