40

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.
howlger
  • 31,050
  • 11
  • 59
  • 99
jumps4fun
  • 3,994
  • 10
  • 50
  • 96

5 Answers5

100

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
howlger
  • 31,050
  • 11
  • 59
  • 99
  • "No ref to fetch from MyRepository - origin - everything up to date." I'll update my question with screenshots – jumps4fun Nov 20 '17 at 11:44
  • 1
    God damnit, in my latest attempts, I just confused two different repositories. So this really does work. Thanks a lot! – jumps4fun Nov 20 '17 at 11:56
  • Make sure that, in the URL field of the above dialog, your fork's URL is shown. – not2savvy Jan 15 '19 at 15:06
  • How could I configure this to all projects? I have to configure it for each project just now. Thank you. – Darkfalk Dec 30 '19 at 13:25
  • 1
    @Darkfalk This configuration is stored in the Git config. So I suppose without having tried it myself, in _Window > Preferences: Team > Git > Configuration_ you can copy this setting from the _Repository Settings_ tab to the _User Settings_ tab to ably it to all Git repositories. – howlger Jan 03 '20 at 17:04
  • Where is “origin” is your remote name – lingar Jun 02 '20 at 13:34
  • 1
    @lingar Yes, thanks. I added this to the answer since the remote might have a different name. – howlger Jun 02 '20 at 15:23
6

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

Lee Chee Kiam
  • 11,450
  • 10
  • 65
  • 87
2

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.

GHajba
  • 3,665
  • 5
  • 25
  • 35
0

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.

-3

What I did: 1: disconnected. 2. refresh and pull. Then, it shows the new branch 3. create local and pull.