10

I would like to do the following in EGit:

$ git checkout -b newbranch
$ git push -u origin newbranch

This gives me a new local branch, pushes it to the upstream server and creates the right tracking reference. How do I do the same in EGit?

1
  • EGit 3.2 finally (February 2014) offers to set the upstream branch when pushing! See my edited answer below
    – VonC
    Feb 7, 2014 at 12:47

2 Answers 2

9

For the first operation, you can read the EGit manual "Creating a New Local Branch "

Select Team > Switch To... > New Branch

new branch dialog

For the push, see Vogella's Egit tutorial, but also the "Push ref specification"

push a branch

Note: robinst has opened bug 378960 "Allow to configure upstream in Push Branch wizard" (mentioned in "EGit - set up remote tracking correctly when creating a branch").

The problem is that this (configuring the upstream on push) is not yet done automatically when first pushing a branch.

For now you have to right click on the branch in the Git Repositories view and choose "Configure Branch", where you can set up the upstream configuration.


Note: bug 378960 has been marked as resolved (February 2014) in Egit 3.2:

Push Branch / Initial Push wizard simplifies pushing a branch and also allows upstream configuration for new branches created by the push operation:

https://wiki.eclipse.org/images/6/6f/Egit-3.2-PushBranchWizard.png

6
  • Sorry, but your answer is not helpful, since its result is not the one I asked for. This way, the new branch still merges from the branch it was created from (e.g. branch.newbranch.merge = refs/heads/master), but I would like to have a proper upstream tracking reference, like the one the -u flag creates.
    – neelance
    Apr 11, 2012 at 22:00
  • @neelance ok I will check that tomorrow
    – VonC
    Apr 11, 2012 at 22:22
  • @neelance I did check, but didn't find an obvious solution for now.
    – VonC
    Apr 19, 2012 at 12:36
  • Opened a bug about being able to do git push --set-upstream here: bugs.eclipse.org/bugs/show_bug.cgi?id=378960
    – robinst
    May 9, 2012 at 11:12
  • For now you have to right click on the branch in the Git Repositories view and choose "Configure Branch", where you can set up the upstream configuration.
    – robinst
    May 9, 2012 at 11:13
0

The UI location for creating a new branch seems strange to me.

In the Git Repository tab, select a branch you want to create a branch from it right click and then you will see Create Branch

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.