Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a new remote branch with EGit?

Let's say I have an Eclipse Project which uses versioning control with EGit and is connected with a remote repository [email protected]:git2013. In my project, under the local branch newstuff, I create and change some files. Now, I want to push this to a remote branch named newstuff in my remote repository. But my remote repository only holds a branch master.

How do I create a new remote branch called newstuff?

PS: Please do not answer with command-line git commands; describe how to do it in EGit.

like image 257
Above Avatar asked May 13 '13 19:05

Above


People also ask

Does git branch create a remote branch?

Actually, Git does not allow creating a (new, isolated) branch on a remote repository. Instead, you can push an existing local branch and thereby publish it on a remote repository.

How do I create a git branch in Visual Studio?

Create a Git branch in Visual Studio To start, make sure you've got a previously created or cloned repo open. From the Git menu, select New Branch. In the Create a new branch dialog box, enter a branch name. For branch naming details, see Special characters in branch and tag names.


2 Answers

In EGit 3.2, there is now a dedicated wizard for this use case:

  1. Select TeamPush Branch... in the context menu

  2. In the wizard, you can change which remote you want to push to and whether pulling on this branch should merge or rebase:

    Push Branch in EGit

  3. The next page will show a confirmation before doing the push, you can then finish the wizard.

After that, you can simply use Push to Upstream when the branch is checked out to push to the remote branch, or Pull to get the changes from the remote branch.

like image 200
robinst Avatar answered Oct 06 '22 23:10

robinst


You can follow the section "Configuring upstream push " in order to push a given branch:

Configure push in Egit

Pushing a branch which doesn't exist yet on a remote repo will create it on said remote.

You can specify the refspec you want to use, or use Push ref specification.

Push refspec

That above would push all local branches.


Update December 2013 (Egit 3.2): as mentioned in robinst's answer (upvoted), you now have:

Push Branch / Initial Push wizard simplifies pushing a branch and also allows upstream configuration for new branches created by the push operation.
Improve UI of upstream configuration when creating a branch:

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

like image 31
VonC Avatar answered Oct 06 '22 23:10

VonC