[英]Git: update master branch from two branches
Me and my friend are working on a project simultaneously so I have created 2 branches branch_a
(I work on it) branch_b
(he works on it) and now we want to merge his work with mine in the master
branch. 我和我的朋友正在同时从事一个项目,因此我创建了两个分支branch_a
(我正在处理) branch_b
(他正在处理),现在我们希望将其工作与我的master
分支合并。
What I do usually when I complete my work is: 完成工作后通常要做的是:
git add *
git commit -m "my new commit"
git push origin branch_a
After that I simply merge my work into the master branch like this: 之后,我只需将我的工作合并到master分支中,如下所示:
git checkout master
git merge branch_a
git push origin master
But when I want to get the work of my friend in branch_b
by doing this: 但是,当我想通过以下方法来获取我的朋友在branch_b
的工作时:
git checkout branch_a
git merge branch_b
I get this message Already up-to-date
!! 我Already up-to-date
收到此消息Already up-to-date
!
How can I fix this problem ? 我该如何解决这个问题?
The most likely explanation here is that your local branch_b
does not have the latest changes/work which your collaborator has pushed to the remote repository. 这里最可能的解释是您的本地branch_b
没有您的协作者已推送到远程存储库的最新更改/工作。 Perhaps the quickest fix would be to just git fetch
and then merge branch_a
with the remote tracking branch for branch_b
: 最快的解决方法也许就是git fetch
然后将branch_a
与branch_a
的远程跟踪分支branch_b
:
git fetch origin
git checkout branch_a
get merge origin/branch_b
Or, if you also want to update the local branch_b
as well, you could git pull
on that branch, and then do the merge with branch_b
: 或者,如果您还想更新本地branch_b
,则可以在该分支上进行git pull
,然后与branch_b
进行合并:
git checkout branch_b
git pull origin branch_b
git checkout branch_a
git merge branch_b
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.