用于本地存储库的 Python 脚本和用于特定提交 GIT 的 Cherry-Pick

问题描述

我想创建一个 python 脚本来制作本地存储库,但我不知道如何做到这一点,在本地存储库之后,我想为特定的提交做cherry-pick。对我有什么建议吗?

解决方法

有关我们在 Python 中创建存储库和一些操作所使用的内容,请参阅以下内容:

创建仓库

repo = git.Repo(os.path.abspath(repo_path))

结帐

repo.git.checkout(branch)
repo.git.checkout(commit_hash)
repo.git.checkout(tag_name)

做cherry-pick commit hash 'fff1234'

repo.git.cherry_pick('fff1234')

您可以参考此网址了解更多详情https://titanwolf.org/Network/Articles/Article?AID=0f484197-1dc3-4676-82c8-5359fad01f33#gsc.tab=0