Skip to content

Instantly share code, notes, and snippets.

@OleksiyRudenko
Last active November 15, 2018 18:31
Show Gist options
  • Save OleksiyRudenko/9ea8918c326131675059cc02c1955d83 to your computer and use it in GitHub Desktop.
Save OleksiyRudenko/9ea8918c326131675059cc02c1955d83 to your computer and use it in GitHub Desktop.
Merge into master preserving history linearity

Merge into master preserving history linearity

WIP

Pre-requisites

Normal feature development at the moment we are ready to merge into master can be illustrated as follows:

     C--M1--F--G--M2
    /  /         /
A--B--D---------H

Desired outcome

A-B-D-H-C'-M1'-F'-G' or A-B-D-H-S' where S' is a squashed feature branch commits

The feature branch can then be deleted.

Also consider group-and-squash commits in feature.

Risks: squashing merger commits, rebasing/cherry-picking merger commits.

How to achieve

WIP hypotheses

git checkout master
git cherry pick C^..M2
git checkout feature
git branch feature-backup
git rebase --onto master feature feature~20 # last 20 commits from feature
git rebase HEAD master

See also:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment