使用JGit:如何推送特定的提交到远程仓库

我需要一些JGit特定的帮助。

我正在寻找使用JGit库的以下等价物:

git push [remotename] [commit SHA]:[remotebranchname]

换句话说:从特定的回购协议中,我想推动一切到另一个远程回购的具体承诺。

org.eclipse.jgit.api.PushCommand似乎允许我仅指定远程名称,但不指定提交ID或远程分支名称。

有人能指出我缺少的东西吗?


它解决了!

在JGit的传输/连接类中进行调试,查看了远程回购的广告引用,发现当我推送提交时,ref refs/remotes/__my_remote__repo__/master正在移动,但ref :refs/heads/master始终停留不变。 这是原因,我没有看到我的变化到达GitHub。

然后,我从以前的版本切换到: commitId + ":refs/remotes/__my_remote__repo__/master" ref-spec to commitId + ":refs/heads/master" ,现在一切正常!

内容现在在https://github.com/my_remote__repo/commits/master上正确显示。

好极了! 谢谢你的帮助。

链接地址: http://www.djcxy.com/p/49813.html

上一篇: Using JGit : How to push a specific commit to a remote repo

下一篇: Delete a commit but keep the changes