Skip to content

Instantly share code, notes, and snippets.

@viktor-evdokimov
Created June 6, 2017 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viktor-evdokimov/156ab9e01840ef6698e9c40962781312 to your computer and use it in GitHub Desktop.
Save viktor-evdokimov/156ab9e01840ef6698e9c40962781312 to your computer and use it in GitHub Desktop.
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
#from https://stackoverflow.com/questions/1628563/move-the-most-recent-commits-to-a-new-branch-with-git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment