从URL获取回购协议的最新标记

2024-04-25 14:28:54 发布

您现在位置:Python中文网/ 问答频道 /正文

找到此答案以帮助使用gitPython和ssh密钥GitPython and SSH Keys?

我想动态使用最新的标记版本,但不克隆repo。。差不多

import os
from git import Repo
from git import Git

git_ssh_identity_file = os.path.expanduser('~/.ssh/id_rsa')
git_ssh_cmd = 'ssh -i %s' % git_ssh_identity_file

with Git().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):
    repo = Git('git@<cdn>')
    # repo = Repo('git@<cdn>') # this doesn't work, gives a 'NoSuchPathError'

latest_tag = # how to get tags?
<do something with latest_tag>

我找不到任何例子,而且我的git python知识非常有限


Tags: fromimportgitcmdoswithrepocdn