简体   繁体   中英

How to work on 2 branches an then merge changes into one?

I would like to know which is the best approach for doing this. I'm curently working on a new design, the old design is still in production and a few bugs came up. So I decided to create a new branch called "old" and fix the bugs there so I can upload the fixes without breaking the design. What happens when the new design is ready and I want the fixes to be applied to the master branch? Which branch merges into which? How do I tell git which files to merge? I don't get it. Thanks.

EDIT: What I think I need is to commit changes in the old branch and replicate them in the master branch. Is that possible?

You can do it in two way, merging or rebasing

for merging

git checkout master

git merge old

then everying in the old branch will be in master branch. but for the old branch, it doesn't have all the things in the master branch if you want to keep 2 branches in sync , you need to

git checkout old

git merge master

You need to checkout master Branch (where you developed the new design) and merge "old" into your branch you have checkout.

In case you just want specifig file(s) you may ether use checkout from other branch or cherry-pick a commit.

checkout from other branch: see the accepted answer from this so question

cherry-pick: see the accepted answer from this so question

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