Arc Forumnew | comments | leaders | submitlogin
1 point by shader 5420 days ago | link | parent

What should I do in git if I have been developing a branch off of master, and I want to move it over to be based on arc3.master so that it will be more forwards compatible?

I haven't changed anything that existed in arc3.master, or master for that matter, just added some new things, and modified them a bit.

I thought I was supposed to use "git rebase arc3.master" while in the other branch, but it seems that didn't work, as it was complaining about merging changes in arc.arc, and I never touch that file in this branch.

Suggestions?



1 point by rntz 5420 days ago | link

Well, first of all, `git rebase --abort` if you haven't already to avoid fucking things up. The actual command you want is `git rebase --onto arc3.master master ${my-branch}`. Explanation follows.

`git-rebase $target $branch` takes the changes made by the commits in $branch relative to its nearest ancestor in $target and attempts to change them to be relative to $target - it "forward-ports" the changes you've made relative to an old version of $target. The problem in your case was that the common ancestor of arc3.master and master is plain old arc2. So what it did was attempt to take essentially the whole of anarki's changes to arc2 (plus whatever changes you were working on) and forward-port it to arc3.master. Something of this magnitude is not really amenable to handling by automatic merge. Conflicts are inevitable, and moreover, a semantic change (like the rename of 'set to 'assign and 'assert to 'set) won't be caught... there's a reason that the arc3 anarki is a fresh start instead of a straightforward port.

`git-rebase --onto $newbase $oldbase $branch`, however, takes the changes made by the commits in $branch relative to $oldbase and tries to forward-port them to $newbase, rather than just taking the nearest shared ancestor. `git-rebase --onto arc3.master master $branch`, therefore, says "take the changes between $branch and master and forward-port them to arc3.master", which is a much more feasible thing to do automatically if those changes haven't touched anything that differs significantly between master and arc3.master.

-----

1 point by shader 5420 days ago | link

Thanks.

I already did the git rebase --abort as soon as it started complaining about something I new I didn't change.

What if master has changed since I started the branch? Should the command instead be 'git rebase --onto arc3.master mybranch~n mybranch'? Or does it not matter where the head of master is relative to the beginning of my branch? Should I rebase to the head of master first, and then move it over to arc3.master?

I guess the documentation on git rebase wasn't quite detailed enough for me ;)

-----