Click here to Skip to main content
15,901,373 members
Articles / All Topics

Get Specific Branch of GitHub Repo Using Xamarin Studio

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
21 Dec 2016CPOL4 min read 4.9K   1  
How to get specific branch of GitHub Repo using Xamarin Studio

A few months back, Miguel de Icaza twitted that they are working on Xamarin Forms version of Mac and I got excited as I always wanted to develop apps for Mac but didn’t want to invest my time in learning the working of Xamarin.Mac and also I am more comfortable and good (that’s what I think ?? ) in Xamarin Forms.

Image 2

The Tweet which got me excited.

From twitter itself, I came to know that there is a separate branch for macOS in Xamarin.Forms Github Repository (Branch Link). I wanted to contribute to this library so I forked it (for those who are new to GitHub, the term forking means copying a Github repository from someone else's public repository to your GitHub account. This way, the actual user will work on his copy and you will work on your own), but to my dismay the copy which was created for my user was of master branch of the Xamarin.Forms repository not the macOS one. Later, I came to know that forking creates a complete copy of the repository you forked in your account along with all its branches. Now the question arises how you will work on the branch you want to work in my case MacOS branch?

I searched about the solution over the internet and finally was able to clone the MacOS branch on my local. This blog is a step by step guide on how to clone a particular branch of any repository using Xamarin Studio. In this blog, I will be cloning the macOS branch of Xamarin.Forms repository.

Step 1

Open the repository you want to fork in Github and click on ‘Fork’ button as shown in the following image:

Image 3

Step 2

Once the fork is complete, you will be redirected to your repository’s page with master branch selected like this:

Image 4

Step 3

Click on Clone or Download button and copy the path mentioned in the text box as shown in the below image:

Image 5

Step 4

Open Xamarin Studio (to clone the repository on your Mac) and click on Version Control–> Checkout... option as shown below:

Image 6

Step 5

The previous step will open the following window:

Image 7

Step 6

Paste the path you copied from the web in the url text-box, it will automatically fill the rest of the fields.

Image 8

Step 7

If you want to change the location where you store the code locally, you can do so by changing the ‘Target Path‘ and then click on checkout to clone the repository locally.

Image 9

Image 10

Step 8

Xamarin Studio will download the master branch of the code and open the solution in Xamarin Studio like this:

Image 11

Step 9

In order to get a particular branch of the code and work with it, we need to set that branch as remote source and create a copy of same. To do so, click on the option Version Control –> Manage Branches and Remotes like below:

Image 12

Step 10

The previous step will open the following window. You can see that by default Branches Tab is selected, which shows all the branches cloned locally. By default, it will be master like below. Click on ‘Remote Sources’ tab as highlighted.

Image 13

Step 11

‘Remote Sources’ tab will show the origin collapsed in Remote Source / Branch with Url as below:

Image 14

Step 11

Click on the arrow adjacent to origin (as highlighted below), which will list down all the branches of the repository (like the next image):

Image 15Image 16

Step 12

Scroll through the list and select the desired branch (macOS in our case) as shown below:

Image 17

Step 13

If you notice the images of Step 11 and 12, you will notice that there is a button titled ‘Track in local Branch’ which was disabled in step 11 and got enabled in step 12 when we selected our desired branch click on button to clone the branch locally.

Image 18

Step 14

You will get the following window to set branch properties in order to set local name, etc. Click on Ok button (Don’t change name as it will help to relate with online branch) and the window will go away. Now if you click on Branches tab, you will see that it will show another branch in the list as shown in the next image. Close the window by clicking on the close button.

Image 19

Image 20

Step 15

Click on Version Control menu and you will see that now there is new option ‘Switch to Branch’ giving an option to change the branch as in the below image. It will still be showing the master branch as checked, click on macOS branch to clone and open.

Image 21

Step 16

The following window will appear once you click on macOS branch in Switch to Branch option, enter your details (your GitHub username and email) and click ok button.

Image 22

Step 15

Xamarin Studio will download the code of the branch and open the solution like below and also you can see the branch name in bracket (as highlighted):

Image 23

Now, you also can download any particular branch of any public code repository from Github and work on the same ??. Let me know if I have missed anything, suggestions or any particular topic in Xamarin you want to know about.

Happy coding!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
Hi There, I am an IT professional with 14 years of experience in architecting, designing and building IT solutions for complex business needs in form of mobile & web applications using Microsoft technologies. Currently working in an multinational company in India as Solutions Architect. The articles here are sourced from my blog : http://techierathore.com/

Comments and Discussions

 
-- There are no messages in this forum --