GitPython: Get current tag (detached head) GitPython: Get current tag (detached head) git git

GitPython: Get current tag (detached head)


You can iterate through tags and compare each tag commit with current head commit:

next((tag for tag in repo.tags if tag.commit == repo.head.commit), None)


It looks like you might be able to get what you want with GitCmd calling describe.

g = Git(git_dir)rval = g.describe()

I don't see any way to directly access this information.