Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » JGit push with --set-upstream(how push a branch to a remote and add upstream (-u option on push command))
JGit push with --set-upstream [message #1551431] Wed, 07 January 2015 16:20 Go to next message
alexandre Escot is currently offline alexandre EscotFriend
Messages: 1
Registered: January 2015
Junior Member
Hello,

I am using JGit in my project and I search a way to push a branch and add the upstream reference (tracking).

It is the option -u or ---set-upstream into the push command.

I don't see a method in the class PushCommand which permit to do this.

Please, could you tell me how I can do this ?

Thanks for your help.

Alex.
Re: JGit push with --set-upstream [message #1554286 is a reply to message #1551431] Fri, 09 January 2015 05:34 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.01.2015 um 14:06 schrieb alexandre Escot:
> Hello,
>
> I am using JGit in my project and I search a way to push a branch and add the upstream reference (tracking).
> It is the option -u or ---set-upstream into the push command.
>
> I don't see a method in the class PushCommand which permit to do this.
That is more like a local config change rather than a remote command. With the Plugin Spy (Alt+Shift+F1) on the
"Configure Branch..." dialog you can open the class org.eclipse.egit.ui.internal.dialogs.BranchConfigurationDialog. It's
okPressed() method shows you what to do:

@Override
protected void okPressed() {
try {
String merge = branchText.getText();
if (merge.length() > 0)
myConfig.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
myBranchName, ConfigConstants.CONFIG_KEY_MERGE,
merge);
else
myConfig.unset(ConfigConstants.CONFIG_BRANCH_SECTION,
myBranchName, ConfigConstants.CONFIG_KEY_MERGE);

String remote = remoteText.getText();
if (remote.length() > 0)
myConfig.setString(ConfigConstants.CONFIG_BRANCH_SECTION,
myBranchName, ConfigConstants.CONFIG_KEY_REMOTE,
remote);
else
myConfig.unset(ConfigConstants.CONFIG_BRANCH_SECTION,
myBranchName, ConfigConstants.CONFIG_KEY_REMOTE);

boolean rebaseFlag = rebase.getSelection();
if (rebaseFlag)
myConfig.setBoolean(ConfigConstants.CONFIG_BRANCH_SECTION,
myBranchName, ConfigConstants.CONFIG_KEY_REBASE,
true);
else
myConfig.unset(ConfigConstants.CONFIG_BRANCH_SECTION,
myBranchName, ConfigConstants.CONFIG_KEY_REBASE);
try {
myConfig.save();
super.okPressed();
} catch (IOException e) {
Activator.handleError(
UIText.BranchConfigurationDialog_SaveBranchConfigFailed, e, true);
}
} catch (RuntimeException e) {
Activator.handleError(e.getMessage(), e, true);
}
}

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Previous Topic:jgit fetch LOCK_FAILURE
Next Topic:S3 Jgit IAM Credentials
Goto Forum:
  


Current Time: Tue Apr 23 07:28:37 GMT 2024

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

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

Back to the top