Created
February 4, 2020 01:25
-
-
Save balanza/231d7270f860f3b84619bf7215f8b107 to your computer and use it in GitHub Desktop.
Git snippets to checkout latest test-passing 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
# get latest commit with passing tests | |
while true; do npm test && break || git checkout HEAD~1; done | |
# count how many commits in between | |
echo $(($(git rev-list --count HEAD..master) - 1)) | |
# checkout where things got broken | |
while true; do npm test && break || git checkout HEAD~1; done; git checkout master~$(($(git rev-list --count HEAD..master) - 1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment