Created
November 14, 2019 15:04
-
-
Save nealfennimore/55dc8bfaa6202fc1d4f303bdbf88d9c5 to your computer and use it in GitHub Desktop.
Git checkout to previous working commit
This file contains 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
# We're currently on `non-working` branch, and we've identified a previous working commit of `abcdef123456`. | |
# We want to go back to commit `abcdef123456`, and then start work anew from there | |
# First checkout to the working commit `abcdef123456` | |
git checkout abcdef123456 | |
# You'll be in a temporary staging area now. If we want to make changes now, we'll need to copy the current commit | |
# into a new branch. | |
git checkout -b previous-working-branch | |
# Now if you check git log, you should see the working commit as `abcdef123456` | |
git log | |
# Outputs: | |
# commit abcdef123456<rest of hash> (HEAD -> previous-working-branch) | |
# Author: Whomever <email@email.com> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment