Skip to main content



      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 11:56 Go to next message
Eclipse UserFriend
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 11:49 Go to previous message
Eclipse UserFriend
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.
Previous Topic:jgit credential helper?
Next Topic:Repository for multiple projects
Goto Forum:
  


Current Time: Sun Jul 13 09:52:58 EDT 2025

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

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

Back to the top