Skip to content

Instantly share code, notes, and snippets.

@jeremy-rutman
Created October 28, 2019 10:18
Show Gist options
  • Select an option

  • Save jeremy-rutman/78c71620a07ebd67b0a618c73e6b5711 to your computer and use it in GitHub Desktop.

Select an option

Save jeremy-rutman/78c71620a07ebd67b0a618c73e6b5711 to your computer and use it in GitHub Desktop.
get the short git hash of current repo
import git
repo = git.Repo(search_parent_directories=True)
sha = repo.head.object.hexsha
short_sha = repo.git.rev_parse(sha, short=1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment