我正在使用库 pygit2 在我的项目中实现一个 git 模块。现在我被这两种情况阻止了: - 删除标签而不是推送 - 删除分支而不是推送
这就是我想要做的:
>>> branch = repo.lookup_branch('origin/1249something', pygit2.GIT_BRANCH_REMOTE)
>>> branch
<_pygit2.Branch object at 0xb7350270>
>>> branch.delete()
>>> branch_to_push = 'refs/remotes/origin/1249something'
>>> pusher = pygit2.Signature('test TESTSSSSSSSS', 'test-test1@site.com')
>>> message = "just test message"
>>> remote_repo = repo.remotes[0]
>>> remote_repo.push(branch_to_push, pusher, message)
这是我得到的结果:
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pygit2/remote.py", line 358, in push
check_error(err)
File "/usr/local/lib/python2.7/dist-packages/pygit2/errors.py", line 56, in check_error
raise GitError(message)
_pygit2.GitError: src refspec 'refs/remotes/origin/1249something' does not match any existing object