Search code examples
eclipsegitlabgit-commitegitgit-push

Unable to fetch the New branch in Eclipse Git Remote Tracking for one machine


I have an Eclipse Project which is maintained in git. After the first commit, yesterday I added new files directly to the master branch (which I later realized was wrong, and should have created a local branch). Today I tried to create a local branch on two machines and tried to push the codes on the respective machines.

STEPS:

  1. Created a new branch in git
  2. Eclipse - Git repository - Fetch from Upstream - added the new branch
  3. Switched to the new branch and checked out
  4. Making new changes to the code

On one machine I could go through these steps smoothly. I am getting stuck on the other machine at #2. I am unable to find the Fetch from Upstream option. I only see Fetch from origin, and when I click on that, system prompts "No ref to fetch".

Fetch from origin

No ref to fetch


Solution

  • In that case, revert to command-line, and check on both machine:

    cd /path/to/repo
    git config -l
    

    Try and compare in both the remote and branch section like:

    remote.origin.url=https://gitlab.com/<user>/<project>
    remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
    branch.master.remote=origin
    branch.master.merge=refs/heads/master
    

    By setting them identical between the two machines repositories, you should then be able to switch back to Eclipse and see the same options again.