简体   繁体   中英

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.
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:

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:

git checkout branch_a
git merge branch_b

I get this message 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. 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 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 :

git checkout branch_b
git pull origin branch_b
git checkout branch_a
git merge branch_b

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM