john2994
john2994

Reputation: 433

Git, connect to remote branch in eclipse

I want to connect to branch that i created in remote git, but i dont know how to do it, i have to connect to this specific branch and not create new one from eclipse. I have connected to master branch, using "clone Git repository". Then i created new branch in remote git using browser, and now i need to connect to this branch. How do i do it? I have tried to fetch from origin, but i am afread to break something because other people also using master branch. Thanks in advance and sorry if it is a damp question.

Upvotes: 1

Views: 1369

Answers (2)

john2994
john2994

Reputation: 433

Right click on repository -> remote -> fetch -> next -> on "source ref" pick your branch -> finish

Upvotes: 1

Panos Gr
Panos Gr

Reputation: 677

To connect to a remote branch you only need to clone the project, which as you mention you've already done.

In the eclipse wiki documentation it is mentioned you can choose which branches to clone. You can choose all of them or only the one you are interested in upon setup. In order to be able to see the code in a cloned branch you will need to create a local copy of it (it may probably be automatically created by Eclipse). Don't worry, you cannot break anything from fetching or pulling since all your changes stay local, you can only break when you push.

Take a look at the docs for a great step by step tutorial on how to clone in Eclipse: https://wiki.eclipse.org/EGit/User_Guide#Cloning_Remote_Repositories

Hope this helped, Panos.

Upvotes: 1

Related Questions