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第三方库


热门话题
java在Android Studio中使用while循环显示包含textview对象的数据   创建名为“userController”的bean时发生java错误:通过字段“userService”表示未满足的依赖关系   java PDFBox PDFImageWrite。writeImage未正确处理所有字符   java无法识别代码中的nzec错误   无法更改java TabLayout字体   在Java中使用子字符串删除部分字符串   Java中的listener addPropertyChangeListener方法   java可以同时拖动多个对象   java如何将数组中的值添加到向量中   java为什么在Camel 3.7.3中无法正确计算属性?   与后端问题不同的机器中的java客户端资源   带字符串的java分割字节数组?   java On_选项_项目_选择的方法说明   java如何在画布的父画中画一个圆?   连接超时和打开连接数的java Netty通道配置   java mysql中如何防止向数据库中插入重复数据   升级到macOS Big Sur后,java无法启动Neo4j控制台应用程序   在Java中使用XSLT将XML转换为HTMLString的ajax   java无法使用Apache POI获取Excel工作表中的数据