Eclipse egit: How to make remote branch local

Viewed 3220

In JIRA, we now have the ability to "create branch" for each issue. This is lovely, but these branches are only created remotely. If the developer then switches to this remote branch, he is oddly unable to push anything to it. This seems to be due to the fact that the branch is not imported into the "local" git repo.

Is there some way to do this?

Note that none of this poses any issue when the branch is created from Eclipse.

No "push" option, for whatever reason:

enter image description here

git config:

[core]
    symlinks = false
    repositoryformatversion = 0
    filemode = false
    logallrefupdates = true
[remote "origin"]
    url = https://[username]@bitbucket.org/[project-name]/[project-name].git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master

... followed by many other branches, none of which is the one I am trying to use.

Here is what the Branches view shows me in Photon when I attempt to check out a branch:

Note the absence of the ellipsis after the "Check Out" option

Note the absence of the ellipsis after the "Check Out" option, which means I don't get to choose to "checkout as local branch".

Installing Photon on Ubuntu, I do see the ellipsis, and everything works just fine as described. Not so much on Windows.

Of course, Eclipse on Linux has tons of other quirks and bugs, so I won't be using that much. I'm old enough to remember when people believed in funny abstract ideals like "platform independence". Sigh...

2 Answers

make sure you have these settings checked in your configuration. Otherwise there will be no dialog asking what to do with your newly checked out branch: Settings for GIT-Checkout

It looks like you are in the detached HEAD state: the black checked-out mark is not on a local branch because you have checked out a commit or a tag.

If you want to make changes to a remote branch, create a local branch that has the remote branch as the upstream branch first (you cannot make changes directly on the remote branch):

  1. Right-click the remote branch, choose Check Out... or
    open the Branches dialog (Ctrl+3 and type branch), select the remote branch and click Check Out...)
  2. In the following dialog click Check Out as New Local Branch (not Check out Commit which leads to the detached HEAD state)
Related