Search code examples
eclipsegiteclipse-pluginegitgit-clone

How to download/clone a new branch from my server git repository into an already created local git repository in my PC with Eclipse EGit


This is driving me crazy.

I created a git repository in a Linux server hosted by my hosting company.

I cloned it to a local copy using Eclipse EGit.

I then created a branch in the original git repository in the server.

How do I copy the branch to my local copy using Eclipse EGit?

When I open Git Repositories inside EGit I see:

- Local
-- master

- Remote Tracking
-- origin/development
-- origin/master

How can I get the origin/development in my local using EGit?

I know I could create a new clone, but I don't want to do that as I believe there must be a way to get only the new branch.

Second question - where is the pull command inside EGit? I was able to find the fetch command, but when I run it it says that there is nothing to fetch. The RefSpec is:

+refs/heads/*:refs/remotes/origin/*

Third question - is there a way to process git commands from a command line inside Eclipse in my Windows system? I thought about trying to do a pull from a command line, but I can't find it in my local system.

Thank you.


Solution

  • Your fetch is up to date because you already have everything copied to your local repository. A pull will merge origin/development into master, which isn't what you want. You want to create a new branch with origin/development as the starting point. I don't know how to do it with egit, but on the command line, you do:

    git checkout -b development origin/development