Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move changes from one branch to another without merge

Tags:

mercurial

I've just realize that I don't understand how to work with such situation:

I have trunk and make a new branch. I'm working with this branch but Also I have to change something in trunk. I switch to trunk, make changes, commit, push. Everything's OK but if I want to want to add all changes from trunk to my branch and I need trunk and branch to exist separately. Because I don't finish with branch but at that time I want fresh changes from branch to be integrated in my branch. If I make merge than I will have just one trunk or just one branch. And in real life I will have 10-30 different branches which should be synchronized with trunk. And every branch can be created in different time with different changeset.

Is there easy way?

like image 675
Max Grigoriev Avatar asked Oct 12 '11 20:10

Max Grigoriev


2 Answers

Er, no, merge is the way. You merge changes from the trunk into your branch, and then you can carry on on the trunk with no problem (update to last trunk changeset, and then commit like you'd always do) — merging does not destroy/close branches. And merge points in the history are the indicators of when and what did you move between development lines.

like image 72
Cat Plus Plus Avatar answered Oct 15 '22 17:10

Cat Plus Plus


Just to add note and example

  • hg glog is your best friend in order to see repository tree and find target for hg up

hg glog (part of) from my repo with 2 active parallel branches and merge-branching in process

o  changeset:   62:eed6619dadb8
|  branch:      Cleanup
|  tag:         tip
|  parent:      59:c9e3b41ec78f
|  user:        Alex Bream <...>
|  date:        Thu Mar 03 19:19:34 2011 +0500
|  summary:     Зачистка по 1-1 131
|
| @  changeset:   61:e7ae9e5f725a
| |  user:        Alex Bream <...>
| |  date:        Thu Mar 03 05:40:34 2011 +0500
| |  summary:     2-9 по 2745
| |
| o  changeset:   60:1393fe759096
|/|  parent:      57:a38258cac9b8
| |  parent:      59:c9e3b41ec78f
| |  user:        Alexander <...>
| |  date:        Thu Mar 03 04:59:22 2011 +0500
| |  summary:     Merge с чистилкой
| |
o |  changeset:   59:c9e3b41ec78f
| |  branch:      Cleanup
| |  user:        Alexander <...>
| |  date:        Thu Mar 03 04:54:11 2011 +0500
| |  summary:     Зачистка пролог полностью
| |
o |  changeset:   58:f7f288c9e72b
| |  branch:      Cleanup
| |  parent:      55:acadd1e83fba
| |  user:        Alexander <...>
| |  date:        Thu Mar 03 04:50:11 2011 +0500
| |  summary:     Зачистка по 47
| |
| o  changeset:   57:a38258cac9b8
| |  user:        Alexander <...>
| |  date:        Thu Mar 03 04:37:49 2011 +0500
| |  summary:     2-9 по 2737
| |
| o  changeset:   56:c838826fadb8
|/   user:        Alexander <...>
|    date:        Thu Mar 03 04:27:40 2011 +0500
|    summary:     2-9 по 2692
|
o  changeset:   55:acadd1e83fba
|  user:        Alex Bream <...>
|  date:        Wed Mar 02 00:39:27 2011 +0500
|  summary:     2-9 по 2640
|

Same part on screenshot from TortoiseHG

TortoiseHG w/branches

like image 36
Lazy Badger Avatar answered Oct 15 '22 19:10

Lazy Badger