python的简单git包装器

python-git-wrapper的Python项目详细描述


Git包装

简单的pythongit包装器

这个库是一个简单的git包装器,允许您以一种强大而简单的方式对任何git存储库执行许多操作。在

要求

这个库已经过python>;=3.7、3.8测试,您需要安装Git>;2.22.0

入门

这个库非常简单,你只需要指出你的存储库在哪里或者创建一个新的。在

from python_git_wrapper import Repository

repository = Repository('.') # Path of your git repository. It could be relative to your project or absolute

或者如果存储库还不存在

^{pr2}$

添加文件:

repository.add_files('path to any file')

提交更改:

repository.commit('commit message')

最后,推动他们:

repository.push()

组件

该库分为3个主要组件。在

  • Git Service:包含与Git进程正确通信的所有数据的对象。在

    • 注意:如果您没有在路径中配置git二进制文件的路径。执行下一个命令:GitService.singleton('git path'')
  • Repository:它将是您的入口点,您将与之交互以提供检索所有信息的功能。它是对要处理的存储库的引用。在

  • Git元素

    • Commit:包含任何提交的所有相关信息

    • Branch:包含分支的名称

    • Status:在工作目录中构建所有更改的对象

API概述

关于此库功能的小概述。所有这些方法和属性都可以被repository对象访问。在

MethodDescriptionReturn
buildCreate or init a new git repositoryRepository
commitCommit the staged changesStatus
statusRetrieve the Status of the Working DirectoryStatus
pushPush Changes to remote repositoryStatus
pullPull changes to remote repositoryStatus
checkoutChange HEAD referenceStatus
create_branchCreate a new branch, go there if necessaryBranch
merge_branchesMerge two branches. Support different merge modesBranch
add_remoteAdd a new remote repositoryStatus
remove_remoteRemove a remote repositoryStatus
executeexecute any git command in the repositorystr
revert_last_commitGenerate a new commit reverting the previous oneCommit
change_last_commit_messageRewrite the previous commit messageCommit
get_commit_by_positionRetrieve Commit by position in the current branchCommit
get_branches_by_commitRetrieve all the branches which contain one specific commitCommit
^{tb2}$

详细的API规范Here。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
我可以用C++代码使用java代码吗?   java使用JSR303在派生类中提供更具体的约束   java在这个查找唯一路径数算法中我做错了什么?   java如何为2个不同的服务提供商使用2个不同的SSL证书?   java在Gridview上绘制文本   java使用连接for循环构建字符串名   java StringBuilder拆分无法处理某些文件   java事件关注EditText   Java Web Start“找不到URL的缓存资源”   java程序从命令行运行的速度比在Eclipse中慢   java为什么HttpServletRequest会截断#字符上的url输入?   java自定义折叠工具栏平滑标题大小调整   使用Mockito对安卓 java中调用另一个静态函数的函数进行单元测试   http在java客户机中使用cachecontrol头   java如何使用。是否使用Delimiter从输入文件中排除标点符号和数字?   使用上下文作为参数/参数的java   java更有效地从Jar中提取文件   java为多个JButton提供相同的actionListener