美文网首页
【git】gitpython

【git】gitpython

作者: 小醉90s | 来源:发表于2018-12-05 21:22 被阅读0次

简介:
git 的 python接口

安装:
pip install git

使用:

repo = git.Repo('c:/SomeRepo')
repo.git.reset('--hard')
Or if you need to reset to a specific branch:

repo.git.reset('--hard','origin/master')
Or in my case, if you want to just hard update a repo to origin/master (warning, this will nuke your current changes):

# blast any current changes
repo.git.reset('--hard')
# ensure master is checked out
repo.heads.master.checkout()
# blast any changes there (only if it wasn't checked out)
repo.git.reset('--hard')
# remove any extra non-tracked files (.pyc, etc)
repo.git.clean('-xdf')
# pull in the changes from from the remote
repo.remotes.origin.pull()

相关文章

网友评论

      本文标题:【git】gitpython

      本文链接:https://www.haomeiwen.com/subject/nskgcqtx.html