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:

  • Can someone explain this interesting git merging behaviour
  • Why is .gitignore not part of repository by default?
  • git-svn branching: how to configure git config
  • Can not create a local and remote branch (tracking) at the same time
  • Git: forks with specific folder's content remaining different in each repo (not considered in merges)
  • Git clone leads to deleted & untracked files
  • A---B---C---D
    

    After:

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

  • Cannot make git diff use diff.external for external diff tool
  • git actions are asking me for username / password on some directories and not for others
  • Git: Communication between boilerplate and ongoing projects
  • Change the branch that git status compares with
  • How can I change which commit master points to in git?
  • Treat directory as a binary or as a single file in git
  • 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.