Anuvrat Parashar Anuvrat Parashar - 1 year ago 99
Python Question

How to do a git reset --hard using gitPython?

Well the title is self explanatory. What will be the python code equivalent to running

git reset --hard
(on terminal) using GitPython module?

Answer Source

I searched for reset in the documentation and found this:

class git.refs.head.HEAD(repo, path='HEAD')

reset(commit='HEAD', index=True, working_tree=False, paths=None, **kwargs)

Reset our HEAD to the given commit optionally synchronizing the index and working tree. The reference we refer to will be set to commit as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download