如何从另一个分支更新Git分支

I was working on a Git branch that was not up to date with changes I was doing on another branch.

我正在一个Git分支上工作,而该分支与我在另一个分支上所做的更改都不是最新的。

So, I had to incorporate those changes. Given a Git branch that’s not up to date with another branch, how do you merge the changes?

因此,我不得不合并这些更改。 给定一个Git分支与另一个分支不是最新的,如何合并更改?

You checkout the branch you want to update:

您签出要更新的分支:

git checkout my-branch

and you merge from the branch you want to update from:

然后从要更新的分支合并:

git merge another-branch

This will create a merge commit, which will include all the differences between the 2 branches - in a single commit.

这将创建一个合并提交,其中将包括两个分支之间的所有差异-在单个提交中。

Also check my Git guide.

另请参阅我的Git指南

翻译自: https://flaviocopes.com/how-to-git-update-branch/