【发布时间】:2017-12-29 07:37:04
【问题描述】:
我可以使用 JGit 将所有本地提交推送到远程(裸存储库)。
RefSpec spec = new RefSpec("master:master");
Iterable<PushResult> resultIterable = git.push().setRemote("origin").setRefSpecs(spec).call();
现在我想将更改推送到特定的提交。下面是 git shell 命令,我需要等效的 JGit 实现。
git push <remotename> <commit SHA>:<remotebranchname>
【问题讨论】:
-
它是否适用于
spec = new RefSpec("<commit SHA>:<remotebranchname>");和.setRemote("<remotename>")? -
已尝试但出现以下错误:org.eclipse.jgit.api.errors.TransportException: remote: error: invalid protocol: Wanted 'old new ref'
-
由于上述异常与 git shallow 有关,因此也尝试了此命令: $ git fetch --unshallow fatal: --unshallow on a complete repository doesn't sense