Get Specific Branch of GitHub Repo Using Xamarin Studio

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.

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 coping a Github repository from someone else 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 complete copy of the repository you forked in your account along with the all it’s branches. Now the question arises that how will you work on the branch you want to work in my case MacOS branch?

I searched about the solution over 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 following image:

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

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

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

Step-5: Previous step will open following window:

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

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.

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

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. Do do so click on the option Version Control –> Manage Branches and Remotes like below:

Step-10: Previous step will open 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.

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

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

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

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.

Step-14: You will get following window to set branch properties in order set local name etc, Click on Ok button (Don’t change name as it will help to relate with online branch) and 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 next image, close the window by click in close button.

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 below Image.It will still be showing the master branch as checked, click on macOS branch to clone and open.

Step-16: 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.

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)

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

🙂 🙂 🙂 🙂 🙂 Happy Coding 🙂 🙂 🙂 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *