git,如何在拉出一个分支后回到原始主节点
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9796328/
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
git, how to I go back to origin master after pulling a branch
提问by fishtoprecords
This has to be a FAQ, but I can't find it googling.
这必须是一个常见问题解答,但我在谷歌上找不到它。
Another person created a branch, commit'd to it, and pushed it to github using git push origin newbranch
另一个人创建了一个分支,提交给它,然后使用 git push origin newbranch 将它推送到 github
I successfully pulled it down using
我成功地将它拉下来使用
git pull origin newbranch
Now, I want to go back to the origin master version. Nothing I do seems to cause the files in the origin master to replace those in the newbranch.
现在,我想回到原始主版本。我所做的一切似乎都不会导致原始主文件中的文件替换新分支中的文件。
git checkout master
git checkout origin master
git pull
git pull origin HEAD
etc
git pull origin master
returns:
git pull origin master
返回:
* branch master -> FETCH_HEAD
Already up-to-date.
This can't be hard, but I sure can't figure it out.
这不难,但我肯定想不通。
'git branch' returns
'git branch' 返回
* master
and 'git branch -r' return
和 'git branch -r' 返回
origin/HEAD origin/experimental origin/master
回答by ralphtheninja
This should work to do what you need:
这应该可以满足您的需求:
git checkout origin/master
回答by Tim
Next time, maybe you can use git fetch first, after that, use git merge.
下次,也许你可以先使用 git fetch,然后再使用 git merge。
This will make your operation more clear.
这将使您的操作更加清晰。
Br, Tim
布,蒂姆