Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to break off a sub-sequence of git commits as a separate branch + merge commit

Tags:

git

What non-interactive git command(s) achieve the change from Before to After (where BC is a merge commit)

Before:

A---B---C---D

After:

  B---C
 /     \
A-------BC---D'
like image 420
James Tauber Avatar asked Feb 12 '11 22:02

James Tauber


1 Answers

Here's what I'd do:

$ git branch to-merge-in C-commit-ID    # Create a branch at C
$ git reset --hard A-commit-ID          # Reset current branch to A
$ git merge --no-ff to-merge-in         # Merge in branch. Create a merge commit.
$ git cherry-pick D-commit-ID           # Grab the commit D
like image 95
mipadi Avatar answered Sep 19 '22 02:09

mipadi