Skip to main content
 首页 » 编程设计

python之Dulwich:如何自动暂存修改后的文件

2025年05月04日9www_RR

在git命令行中,我们可以使用git commit -a。

我如何使用 dulwich 做到这一点?

请您参考如下方法:

考虑提交的各种测试时,如 test_repository.py 中的那些,这似乎不可能在一行中:

    r.stage(['a']) 
    commit_sha = r.do_commit('modified a', 
                             committer='Test Committer <test@nodomain.com>', 
                             author='Test Author <test@nodomain.com>', 
                             commit_timestamp=12395, commit_timezone=0, 
                             author_timestamp=12395, author_timezone=0) 

在调用提交之前,您需要先找到修改或删除的文件,并将它们暂存。

另一种选择是使用 git-python ,它是 git 的包装器,但它不提供任何开箱即用的功能。