2

I need some JGit specific help please.

I am looking to the equivalent of the following using JGit library:

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

In other words: from a particular repo, I'd like to push everything upto a specific commit to another remote repo.

The org.eclipse.jgit.api.PushCommand seems to be allowing me to specify only the remote name, but not the commit id or the remote branch name.

Could someone please point out what I am missing?

Rüdiger Herrmann
  • 20,512
  • 11
  • 62
  • 79
Roshan
  • 290
  • 3
  • 16
  • Update : I tried adding a RefSpec to the PushCommand with source = [commit id] and destination = [refs/remotes/__my__remote__name__/master], but this also hasn't helped. – Roshan Mar 19 '15 at 16:50

1 Answers1

1

It got solved!!

Debugged inside JGit's transport / connection classes, looked at the advertised refs of the remote repo and found that as I was pushing my commits, the ref refs/remotes/__my_remote__repo__/master was moving but the ref :refs/heads/master was always staying unchanged. That was the reason, I wasn't seeing my changes reaching the GitHub.

I then switched from the earlier : commitId + ":refs/remotes/__my_remote__repo__/master" ref-spec to commitId + ":refs/heads/master" and it all works fine now!

The content now shows up correctly on https://github.com/my_remote__repo/commits/master.

Yay! Thanks for your help.

Roshan
  • 290
  • 3
  • 16