Git:区别“git rebase origin/branch”VS“git rebase origin branch”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29164321/
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: difference "git rebase origin/branch" VS "git rebase origin branch"
提问by Adam
Does anyone know what is the difference? Seems to me, it is the same. But when I run it, it didn't do the same thing:
有谁知道有什么区别?在我看来,是一样的。但是当我运行它时,它没有做同样的事情:
git rebase origin/branch
- ok rebases from remote branch
git rebase origin/branch
- 好的从远程分支变基
git rebase origin branch
- makes conflicts
git rebase origin branch
- 制造冲突
回答by svlasov
git rebase <upstream> <branch>
is equal to
等于
git checkout <branch>
git rebase <upstream>
By default <branch>
is HEAD
.
默认<branch>
为HEAD
.
[1] https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html
[1] https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html
回答by Xiongmin LIN
@Mar's answer is right and perfectly solved this question, just add one comment.
@Mar 的回答是正确的,完美地解决了这个问题,只需添加一条评论。
if you want to rebase a branch based on remote master branch, git rebase origin/master
is not enough, it will not get new commits directly from origin/master. You need to git fetch
before 'git rebase origin/master'.
如果你想基于远程 master 分支对一个分支进行 rebase git rebase origin/master
,这还不够,它不会直接从 origin/master 获得新的提交。你需要git fetch
在 'git rebase origin/master' 之前。
or you can use another way to rebase a branch.
或者您可以使用另一种方式来重新设置分支。
- switch to master
git checkout master
git pull origin master
- switch back to your own branch
git checkout {your branch}
git rebase origin/master
- 切换到主
git checkout master
git pull origin master
- 切换回自己的分支
git checkout {your branch}
git rebase origin/master
then, your branch is updated to newest commits.
然后,您的分支将更新为最新的提交。
回答by zhu sheng
The last step should be: git rebase origin/master
最后一步应该是: git rebase origin/master