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

前端 未结 3 1608
伪装坚强ぢ
伪装坚强ぢ 2021-02-19 09:47

Well the title is self explanatory. What will be the python code equivalent to running git reset --hard (on terminal) using GitPython module?

3条回答
  •  无人共我
    2021-02-19 10:15

    You can use:

    repo = git.Repo('repo')
    # ...
    # Remove last commit
    repo.head.reset('HEAD~1', index=True, working_tree=True)
    

提交回复
热议问题