Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
move last commit to the new branch
# Moving to a new branch
# Unless there are other circumstances involved, this can be easily done by branching and rolling back.
# Note: Any changes not committed will be lost.
git branch newbranch # Create a new branch, saving the desired commits
git reset --hard HEAD~1 # Move master back by 3 commits (GONE from master)
git checkout newbranch # Go to the new branch that still has the desired commits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment