Skip to content

Instantly share code, notes, and snippets.

@elalemanyo
Created October 12, 2018 12:09
Show Gist options
  • Save elalemanyo/b6990bd14bbade6e424587d03aff76f8 to your computer and use it in GitHub Desktop.
Save elalemanyo/b6990bd14bbade6e424587d03aff76f8 to your computer and use it in GitHub Desktop.
Moving commits to a new branch

WARNING: This method works because you are creating a new branch with the first command: git branch newbranch. If you want to move commits to an existing branch you need to merge your changes into the existing branch before executing git reset --hard HEAD~3

git branch newbranch 
git reset --hard HEAD~3
git checkout newbranch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment