Created
April 18, 2016 17:31
-
-
Save hartfordfive/8962c872d8235cec085b41bc5f5ec7ae to your computer and use it in GitHub Desktop.
Move accidental commit on "master" to another branch [Git]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| In the situation you've accidentally already committed changes to your "master" branch and want the moved to a seperate branch: | |
| git branch [NEW_BRANCH_NAME] # Create new branch with the changes you just committed | |
| git reset --hard HEAD~[NUM_COMMITS] # Go back [NUM_COMMITS] commits. You *will* lose uncommitted work.*1 | |
| git checkout [NEW_BRANCH_NAME] # Checkout the newly created branch that contains your modifications |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment