简体   繁体   中英

Git: Get changes from master to a remote branch

I am working on a project and we have development branches. Lets say we have branches: master, A, B

Let's say that history looks like this right now:

   7  
   |   
   6  merge commit
   |/ |
   4  |
   |  |
   3  |
   |  |
   a  5   b
    \ | /
      2 
      |
      1
      |
      m

where m, a and b are the branches and numbers are just commits. So I did some work on master, then created branch a, then did some work on a AND some work on master and then some work on a and then merged.

**Question is: ** What is the right way to get the commit 5 into branch a?

If it was a local branch I could just

git checkout a
git rebase master

But a is a remote branch and I know it is not safe to mess with remote history like that. What is the correct way of getting changes from master?

  1. create a local branch a tracking remote/a
  2. git checkout a
  3. git merge master
  4. git push

You already merged one way; was there a specific reason you reached straight for rebase instead of merge in the other direction?

Is it because you previously used some other VCS with broken merges? If so I can reassure you that git is perfectly capable of finding the common ancestor and performing a sane merge here.

Just merge master into a:

git checkout a
git merge master

Done a thousand times, no problem.

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