我需要删除一个远程分支,并发现这种技术:
git push origin:the_remote_branch
我尝试以下列形式将它传递给Networks Push方法,但似乎没有任何工作(options是我的登录凭据):
_repo.Network.Push(_repo.Network.Remotes["origin"], "origin/:NewBranchForDeletion", options)
_repo.Network.Push(_repo.Network.Remotes["origin"], ":NewBranchForDeletion", options)
_repo.Network.Push(_repo.Network.Remotes["origin"], ":origin/NewBranchForDeletion", options)
_repo.Network.Push(_repo.Network.Remotes["origin"], ":refs/remotes/:origin/NewBranchForDeletion", options)
_repo.Network.Push(_repo.Network.Remotes["origin"], ":refs/remotes/origin/NewBranchForDeletion", options)
_repo.Network.Push(_repo.Network.Remotes["origin"], "refs/heads/:origin/NewBranchForDeletion", options)
_repo.Network.Push(_repo.Network.Remotes["origin"], "refs/heads/:NewBranchForDeletion", options)
Run Code Online (Sandbox Code Playgroud)
还有其他一些选择.我根本无法工作,它会返回错误,例如(对于":NewBranchForDeletion"方法):
不是有效的参考"NewBranchForDeletion"
感谢@Rob在LibGit2Sharp的回购中发现了这条评论:https://github.com/libgit2/libgit2sharp/issues/466#issuecomment-21076975
第一个选项失败,NullReferenceException启用了on objectish,并在上面提到的错误中使用string.Empty了objectish结果.第二个选项是我正在尝试的,除了我使用的是HTTPS验证版本:
repo.Network.Push(repo.Remotes["my-remote"], objectish: null, destinationSpec: "my-branch");
// Or using a refspec, like you would use with git push...
repo.Network.Push(repo.Remotes["my-remote"], pushRefSpec: ":my-branch");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
643 次 |
| 最近记录: |