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

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

Before:

  • Using git to merge two directories with common parent (but different SHA1)
  • Does git svn support svn:needs-lock?
  • sysopen permission denied
  • Composer dependency with minor differences in composer.json file
  • Who is successfully using git-flow?
  • Git stash on windows extremly slow compared to Libgit2
  • A---B---C---D
    

    After:

      B---C
     /     \
    A-------BC---D'
    

  • How to deploy a plugin to Jenkins Hosting?
  • Which Xcode project files can I 'exclude' from my git repo?
  • Restore file from old commit in git
  • Gitflow Release Tagging Model Creates A Dilemma
  • GIT: Any way to set default login credentials?
  • Rebasing to change parent of a merge commit
  • One Solution collect form web for “how to break off a sub-sequence of git commits as a separate branch + merge commit”

    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
    
    Git Baby is a git and github fan, let's start git clone.