是否有一种方法可以仅使用gitpython库来应用补丁(以diff文件的形式)到一个存储库中?
换句话说,是否有与git-apply命令等效的gitpython命令?
r = Repo('path-to-repo')
r.git.execute(['git','apply','patch.diff'])
我之前也尝试过这个,但是在参数列表开头省略了“git”,导致命令不存在报错。
repo = git.Repo('repository_path')
repo.git.apply(['-3', 'patch-file'])
git apply -3 patch-file
r.git.execute
,最后清理文件。 - Nishant