我们正在尝试自动提交对旧目录的更改,在那里人们不想使用版本控制(sight)之类的东西。在
我每天晚上都在使用gitpython提交这些更改:
repo = git.Repo(local_directory)
changed_files = [change.a_blob.path for change in repo.index.diff(None)]
if changed_files or repo.untracked_files:
if changed_files:
repo.git.add(update=True)
if repo.untracked_files:
repo.git.add(repo.untracked_files)
repo.git.commit(message='Auto committed')
repo.remotes.origin.push(repo.head)
有时提交失败,并返回“git commit--message=Auto committed”,退出代码为1—我无法重现
我做错什么了吗?我读过也许我应该用回购指数做出承诺?在
最好的, 克里斯托弗
你是绝对正确的你需要使用回购指数做出承诺。下面是我的脚本中使用GitPython的一个工作示例(它顺便帮助我们进行版本控制)
然后是我的提交版本函数:
^{pr2}$所以你可以把“Auto-committed”作为你的
commit_msg
传入。希望这有帮助!在相关问题 更多 >
编程相关推荐