Skip to content

Instantly share code, notes, and snippets.

@ludwigschuster
Created August 10, 2017 13:22
Show Gist options
  • Save ludwigschuster/2963dac2f7c6afeacc063bea89c72f75 to your computer and use it in GitHub Desktop.
Save ludwigschuster/2963dac2f7c6afeacc063bea89c72f75 to your computer and use it in GitHub Desktop.
move Commits from one Branch to another
git branch newbranch # Create a new branch, saving the desired commits
git reset --hard HEAD~3 # Move master back by 3 commits (GONE from master)
git checkout newbranch # Go to the new branch that still has the desired commits
git reset --hard a1b2c3d4
# Existing Branch
git checkout existingbranch
git merge master
git checkout master
git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.
git checkout existingbranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment