简体   繁体   中英

Git rebase multiple merges/branches

I have a scenario where I have made a branch off master, lets call it A, made some changes. Then had to branch off A, let call it B, and made some more changes. I then merged B into A, so now A has both the commits from A and B.

I now need to rebase branch A onto master and squash the commit from branch B, but when I do this I lose all the changes that were on branch B and only the changes from branch A are there.

I am wondering how do I rebase onto master squash the commits and still have all the changes?

If you want to squash the commits from B, then:

  1. rebase B onto A first
  2. squash B so now it is a single (or similar) commit on top of A
  3. rebase A onto master

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