GitPython create and push tags

Thzith picture Thzith · Mar 7, 2016 · Viewed 7.4k times · Source

In a python script, I try to create and push a tag to origin on a git repository. I use gitpython-1.0.2.

I an able to checkout anexisting tag but no way to find how to push a new tag to remote.

Many thanks

Answer

Thzith picture Thzith · Mar 7, 2016
new_tag = repo.create_tag(tag, message='Automatic tag "{0}"'.format(tag)) 

repo.remotes.origin.push(new_tag)