If you’ve attended any of the Python and Flask courses that Susan Ibach and I have delivered, or many of the other development MVAs lately, you no doubt noticed we’ve been sharing our code via GitHub.
GitHub, if you’re not familiar with the service, is the de facto choice for most open source developers, as well as those looking to play with code. GitHub offers tools for issue tracking, wikis and documentation. Put simply, it’s a great web site used for storing source code and developer collaboration.
Inside of GitHub you can create what are known as repositories, or repos as the cool kids like to say. Repos are containers for files of almost any variety, and those files can be organized into folders.
The main question becomes, “How do I download the source shared on GitHub?”
The first, and simplest, is to use the Download Zip button on the lower right-hand corner. This button, as you might expect, will zip up the contents of the repository and allow you to download it. From there you can extract the contents to a folder of your choice and away you go from there. The downside is that is a bit of a manual process.
The second option is to clone the repository. Cloning a repository will give you a copy of the code, and allow you to download (or sync) any changes that are made to that repository later. The nice part about cloning is it integrates nicely with Visual Studio, and you can keep current on any changes. The downside is you’re not able to easily modify the code on your own as any changes you make would be overwritten the next time you chose to sync. That said, generally speaking, after an MVA is recorded few changes are made to the repository.
To clone a repository, simply click the copy button (the one that’s circled) under the HTTPS clone URL heading on the lower right.
Then, in Visual Studio, open the Team Explorer (View > Team Explorer), and click the Connect button (the one that looks like a plug).
The last step is to paste the copied URL into the URL textbox in Visual Studio and click Clone. This will download all of the files into a folder located at C:\Users\<your username>\Source\Repos\<repo name>. After the files are downloaded you can double click on the clone name and it will list all of the Visual Studio solutions for that repo.
The final option, and probably the best option, is to fork the repo. Forking will give you a completely separate copy of the repo on your own GitHub account. The advantage to forking the repo is you are free to make whatever changes you like to the repo as it’s all yours.
To fork a repo, logon to GitHub. Then navigate to the GitHub repo you wish to fork, and then click Fork in the upper right-hand corner. GitHub will then prompt you asking which account you’d like to use (if you have multiple), and then fire up its copy machine to duplicate the code.
Once the fork is created you have a new repo that is all yours with all of the code shared from the MVA. You can then clone that new repo into Visual Studio using the exact same steps above (click the copy button, then go into Visual Studio and clone the repo).
Going forward you’ll notice most, if not all, MVAs that focus on developer topics will be using GitHub to share code. If you’re looking to put your newly honed skills to use, join Susan and I as we head back into the studio to close out our Python and Flask trilogy, digging deeper into Flask development and introducing relational databases. See you then!
I’m not actually a cool kid, but this is what I’ve been told.