Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » How to push a specific commit to a remote repo
How to push a specific commit to a remote repo [message #1687320] Thu, 19 March 2015 15:56 Go to next message
roshan dawrani is currently offline roshan dawraniFriend
Messages: 1
Registered: March 2015
Junior Member
Hello,

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 SHA id or the remote branch name.

Could someone please point out what I am missing?

Regards.
Roshan
Re: How to push a specific commit to a remote repo [message #1688389 is a reply to message #1687320] Fri, 20 March 2015 15:49 Go to previous message
Christian Halstrick is currently offline Christian HalstrickFriend
Messages: 269
Registered: July 2009
Senior Member
What you would like to specify with "[commit SHA]:[remotebranchname]" is the so-called refspec. And PushCommand has "setRefSpecs(RefSpec... specs")". Code like
git.push()....setRefSpecs(new RefSpec("1234567890abc:master")).call()

should do the trick.


Ciao
Chris
Previous Topic:jgit credential helper?
Next Topic:Repository for multiple projects
Goto Forum:
  


Current Time: Mon Apr 06 22:23:52 GMT 2020

Powered by FUDForum. Page generated in 0.12430 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top