如何使用不同的gitdir和worktree路径创建GitPython Repo对象?

2024-10-03 09:07:59 发布

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

从我用来执行此操作的命令行:

$git --git-dir=/opt/git/annotation.git --work-tree=/path/to/worktree/ commit  -m 'commit message command line'

现在,我必须使用GitPython从python脚本调用git,这是我尝试的:

^{pr2}$

我有:

  File "/path/to/script.py", line 54, in git_commit
    repo.index.add('/path/to/worktree/')
    ...
    raise InvalidGitRepositoryError("require non-bare repository")
InvalidGitRepositoryError: require non-bare repository

Tags: topath命令行gitrepositorydirlinerequire