git 将 master 的更改合并到我的分支中
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/41045548/
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
Merging changes from master into my branch
提问by Darth.Vader
I have two branches in git: master
and custom_branch
.
我在 git:master
和custom_branch
.
Somebody added some code to master
that I need to use in my custom_branch
. I tried this:
有人添加了一些代码master
,我需要在我的custom_branch
. 我试过这个:
git branch custom_branch
git merge master
But when I do that, it says:
但是当我这样做时,它说:
Already up-to-date.
But, when I compare master
and custom_branch
, the changes are still not there. What am I missing?
但是,当我比较master
和 时custom_branch
,变化仍然不存在。我错过了什么?
P.S. I don't want to rebase
since other people also use this branch.
PS我不想rebase
因为其他人也使用这个分支。
回答by tehp
git checkout custom_branch && git rebase master
git checkout custom_branch && git rebase master
This will update custom_branch
with changes from master
branch.
这将custom_branch
随着master
分支的更改而更新。
Don't forget to make sure master
is up to date first. git pull
不要忘记首先确保master
是最新的。git pull
This is also possible with git checkout custom_branch && git merge master
这也可以与 git checkout custom_branch && git merge master
有关为什么第一个是(可能)您应该使用的解释: When do you use git rebase instead of git merge?你什么时候使用 git rebase 而不是 git merge?