There are lots of open source projects hosted on Git repositories as well as bloggers and authors publishing demos, patterns and code samples on web-hosted Git repositories such as GitHub, Bitbucket, Codeplex (Note: Codeplex has several source control options and Git is just one of them)….
It is a very convenient way to distribute code samples so that developers can browse the code through Visual Studio and eventually run it and toy with it.
Nevertheless, I often see people getting code from Git repositories by downloading a zip file, unzipping it and then opening it up in Visual Studio. This is fine but there is actually a better way to grab code from Git repositories through Visual Studio.
The technical term to get code from a Git repository for the first time is to clone the repository. I will here under demonstrate how to get code hosted on a Git repository for the first time (aka clone the repository).
If you have never used Git repositories, you can check previous articles I wrote on the topic and notably where I detail Git support for various versions of Visual Studio: Git TFS Visual Studio Integration.
Understand the pros and cons of different source code hosting services. Open and close the navigation menu. How to choose the best source code repository. Is it an established project with a long history that can take some time to download? Bitbucket code repository. Why choose Bitbucket Cloud as your code repository. Source file area: View the directory of files in Bitbucket. From the Source page, click New file in the top right corner. This button only appears after you have added at least one file to the repository. Learn about code review in Bitbucket Cloud Start next tutorial.
The sample hereunder shows how to clone a Git repository from GitHub but the principle is the same for every Git repositories:
1. Getting the clone link from the Git repository:
2. Cloning the repository from Visual Studio:
In Visual Studio 2012 or above, open Team Explorer and click on the Connection button:
Under the Local Git Repositories section, click the Clone link and paste the link copied in the previous step. Choose a folder on your local machine to copy the code to. Finally, click the Clone button located under.
How To Download Source Code From Bitbucket 10
3. Opening the Visual studio solution from the cloned repository:
Upload Files To Bitbucket
Once the Git repository is cloned, it means it has been downloaded on the local machine and Visual Studio’s Team Explorer window will display the message “The repository was cloned successfully”.
In Visual Studio 2012, there is no direct way to open the cloned Visual Studio solution so we have to right-click the cloned repository and click the option Open in File Explorer to find the Visual Studio solution from the file system:
In Visual Studio 2013, Visual Studio integration with Git is better and we can open the solution directly from Visual Studio. To do so, first open the cloned repository by double clicking on it:
Once in the local Git repository, Visual Studio’s Team Explorer will display the Visual Studio solution and we can double click on it to open it: