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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:39:58  来源:igfitidea点击:

Merging changes from master into my branch

gitgithubversion-controlgit-merge

提问by Darth.Vader

I have two branches in git: masterand custom_branch.

我在 git:mastercustom_branch.

Somebody added some code to masterthat 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 masterand custom_branch, the changes are still not there. What am I missing?

但是,当我比较master和 时custom_branch,变化仍然不存在。我错过了什么?

P.S. I don't want to rebasesince 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_branchwith changes from masterbranch.

这将custom_branch随着master分支的更改而更新。

Don't forget to make sure masteris 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?