将更改从 master 合并到我的分支

我在 git 中有两个分支: mastercustom_branch

有人给 master加了一些代码,我需要在我的 custom_branch中使用这些代码:

git branch custom_branch
git merge master

但是当我这样做的时候,它说:

Already up-to-date.

但是,当我比较 mastercustom_branch时,仍然没有变化。我遗漏了什么?

另外,我不想使用 rebase,因为其他人也使用这个分支。

186626 次浏览

git checkout custom_branch && git rebase master

This will update custom_branch with changes from master branch.

Don't forget to make sure master is up to date first. git pull


This is also possible with git checkout custom_branch && git merge master


For an explanation on why the first one is (probably) what you should be using: When do you use git rebase instead of git merge?

Answering my own question but to pull changes from upstream's master into my custom branch I did this:

git pull [URL TO UPSTREAM'S REPO] master

git merge master will update your current branch with the changes from your local master branch, the state of which will be that of when you last pulled while on that branch.

I think this is what you are looking for: git merge origin master

You probably still have to pull the changes to your local master branch. Before your commands, use git checkout master and then git pull

Just do:

git fetch origin master

And then do:

git merge master