Skip to content

Instantly share code, notes, and snippets.

@balanza
Created February 4, 2020 01:25
Show Gist options
  • Save balanza/231d7270f860f3b84619bf7215f8b107 to your computer and use it in GitHub Desktop.
Save balanza/231d7270f860f3b84619bf7215f8b107 to your computer and use it in GitHub Desktop.
Git snippets to checkout latest test-passing commit
# 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