简体   繁体   中英

git: merging changes from multiple branches

I was working on feature branch fb1 and realized I needed some new features, but they should happen on master . So I branched master to fb2 and built my features.

Now fb2 needs testing before I merge it into master but I'd like to continue working on fb1 in the mean time. However I need fb1 to contain the changes on fb2. They both need to stay up to date with master.

I have tried to merge from both branches, and also like fb1 < fb2 < master, but both of those got ugly fast and I ended up backing out.

I would to learn a new workflow for this if anyone has suggestions.

You can rebase fb1 onto fb2:

git rebase --onto fb2 master fb1

Git will take the commits between master and fb1 and re-creates them on top of fb2 that look the same. Do not rebase already published history and make sure you understand the implications. For first-time rebase users backups are recommended ;)

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