[MITgcm-support] closing PR branch without losing subsequent branch (i.e. how to rebase)

Edward Doddridge edward.doddridge at utas.edu.au
Wed Jan 1 18:07:56 EST 2020


Hi Dan,

`git rebase master` is the correct command, but there are complications because the history of `branch_remeshing` is somewhat torturous.

The feature branch you are trying to rebase has had `master` merged into it multiple times. Conceptually, rebase moves all the commits from a branch and places them at the end of the branch you are rebasing onto (in this scenario it’s `master`), but your feature branch contains commits where `master` has been merged into the feature branch, which means a straight `rebase` can’t preserve all of the history. I think this is why you are getting the conflicts - they were resolved by merges in the history, but rebasing means those merges are dropped by default.

You might find this Stack Overflow question and answer to be helpful: https://stackoverflow.com/questions/4783599/rebasing-a-git-merge-commit

I’ve never tried rebasing with the ` --preserve-merges` flag, but I think it’s what you need if you want to do this. However, I’m not certain that rebasing is the best idea… You’ve got a complicated git history, with lots of changes and multiple different branches. If it were me, I’d stick with merges and the ugly history, or create a fresh branch and manually transfer the changes to that new branch.

Cheers,
Ed


________________________________
Edward Doddridge
Research Fellow
Australian Antarctic Program Partnership (AAPP)
Institute of Marine and Antarctic Studies (IMAS)
University of Tasmania (UTAS)

www.doddridge.me<http://www.doddridge.me>

On 25 Dec 2019, at 02:55, Daniel Goldberg <dngoldberg at gmail.com<mailto:dngoldberg at gmail.com>> wrote:

Hello All

I had a long outstanding development branch corresponding to a pull request (branch_remeshing), and in the interim i created a branch off of this branch (branch_horiz_remeshing). With J-M's help the initial branch is now merged, so now i have the following:

1) my initial branch (branch_remeshing) is identical to master.
2) my subsequent branch ( branch_horiz_remeshing) is merged with my initial branch.

and I would like it to be as if my branch-of-a-branch was instead a branch of master. from my reading of stackoverflow etc it seems like this should just be a simple call to

git rebase master

while the branch-of-a-branch is checked out, and this should be without issue. However i am getting extensive merge conflicts, even though i have already merged the branches. Is there a better/proper/preferred way to do this?

Apologies for mailing this list rather than one dedicated to git, but a bit of googling seemed to suggest the above, and i would like to adhere to MITgcm best practice anyhow.

Best
Dan
_______________________________________________
MITgcm-support mailing list
MITgcm-support at mitgcm.org<mailto:MITgcm-support at mitgcm.org>
http://mailman.mitgcm.org/mailman/listinfo/mitgcm-support



University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.mitgcm.org/pipermail/mitgcm-support/attachments/20200101/93f1d5bb/attachment.html>


More information about the MITgcm-support mailing list