从我使用的命令行执行此操作:
$git --git-dir=/opt/git/annotation.git --work-tree=/path/to/worktree/ commit -m 'commit message command line'
现在,我必须使用GitPython从python脚本调用git,这就是我尝试过的:
# script.py
from git import *
repo = Repo('/opt/git/annotation.git')
repo.index.add('/path/to/worktree/')
repo.git.add('/path/to/worktree/')
repo.git.commit(m='commit message from script')
我有:
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