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:

  • If we delete a branch on the server, can we automatically delete it in our local copy?
  • How are you structuring your Git repository workflow?
  • Is there a keyboard shortcut for stage lines in git gui?
  • How do I push to the current git branch on remote, and have changes reflected immediately?
  • Git: Maintaining third-party modules consisting of multiple directories
  • Implementing 'successful git branching model' step by step
  • A---B---C---D
    

    After:

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

  • VS Code configuring Git Sync
  • How do I fix these spurious git commits?
  • Get collections of diffs
  • Copying git local branch between machines?
  • Keep a git feature branch up to date with master branch by pulling directly from the master
  • git repository cloning logging
  • 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.