How do I get a new branch to show up in Eclipse Git Remote Tracking?

Viewed 60098

I have an existing Eclipse git project, with a master and development branch present in both local, and remote tracking. I have just added a new branch in my git repository, but I can't figure out how to get it to show up in Eclipse.

I have tried to read up on the subject, but it seems like it is just expected to automatically show up. I have found a lot of similar questions, but they all seem to deal with the issues of a completely empty remote tracking folder, instead of my problem of only a single new branch missing. I already have Master and Develop present.

Here is what does not work:

  • Clicking refresh in the Git repositories window.
  • Any kind of synchronize, pull or other update I can find

Here is what would work:

  • Right clicking the remote tracking folder, and selecting "Paste repository path or URI". If I do that, and select the exact same path as is already there, I can see my new branch. This action does require that I completely clone the whole repository to an empty folder again, and that can't be how this is intended to work.
  • I believe it might work to use some kind of command line tool, but I really want an Eclipse solution to this, as I feel sure it exists, and I am just missing something.
5 Answers

In the Git Repositories view:

  1. Right-click the repository and choose Fetch from Upstream
  2. If the new branch will not shown up below Branches/Remote Tracking, you have to configure fetch:
    1. Right-click the fetch node below Remotes/origin and choose Configure Fetch...
    2. In the Configure Fetch make sure there is only the single Ref mapping (assuming the remote is named origin) +refs/heads/*:refs/remotes/origin/*:
      Configure fetch

In case you do not see Fetch from Upstream after right-click the repository, you may look for Fetch from origin.

enter image description here

You need to modify the "config" file in your local git repository folder. For example, you cloned a remote branch Project into c:\git\MyProject local folder. In this folder there is a hidden folder ".git" that has a "config" file. There is a section in this file resembling the below

[remote "origin"] url http://xxxxxxxxxxxxxxxx fetch = +refs/heads/Project:refs/remotes/origin/Project

You need to modify this section as below [remote "origin"] url http://xxxxxxxxxxxxxxxx fetch = +refs/heads/:refs/remotes/origin/

Then go back to Eclipse IDE, right click on the repository and do a "fetch from origin". Now all the branches will show up.

For me the solution was almost what Joshua suggested, however it did not work as described. For me the solution was to configure the [remote "origin"] property as follows:

[remote "origin"]
    url = your_git_url.git
    fetch = refs/heads/*:refs/remotes/origin/*

Alternatively, you can do it from the Eclipse UI too:

Fetch from origin... then hit Configure... and in the configuration window hit Advanced... and there you have the option to Add predefined specification where you can selec Add All Branches Spec. This will result in the same configuration as above:

Advanced fetch configuration menu

Maybe you have to remove your original entry which will be pointed out as a duplicate by Eclipse.

Related