Lesson 15.4: Using GitHub to upload and download a solution

This will be the last cleanup lesson for a while. After this, we’ll get back to adding more features to the game.

In this lesson, I’ll show you the basics of using GitHub in Visual Studio: how to get the latest code for this game, and how to create your own GitHub repository for version control of your programs or to share your program with other programmers.

I’m going to show how to do this using Visual Studio 2019.

You can install Git for the command line, or download the GitHub Desktop app from https://desktop.github.com/, although I won’t use those tools in this video.

 

 

 

Lesson Steps

 

Cloning a project from GitHub

When you’d like to get some code from GitHub, you can “clone” the repository – make your own copy of it.

 

Find the repository in GitHub and click on the “Clone or download” button.

Copy the URL listed for the repository. The URL for the SOSCSRPG project is: https://github.com/ScottLilly/SOSCSRPG.git

Open Visual Studio 2019 and click on “Clone or check out code”.

Paste in the URL to the GitHub repository and select the folder you want to clone the source code to on your computer. The folder must be empty.

Click on the “Clone” button and Visual Studio will pull down the source code and open the solution.

Now you can start working on your copy of the program.

 

Upload your own project to GitHub

Now, let’s upload a new project to GitHub. For this example, I created a test project named GitHubDemo.

 

First, install the GitHub extension. From Visual Studio’s menu, select Extensions -> Manage Extensions – Search for (and install) GitHub Extension for Visual Studio

Next, in Visual Studio 2019’s menu, select Tools -> Options -> Source Control -> Select “Git”.

 

In the lower-right corner of Visual Studio, click the “Add to Source Control” message and select “Git”.

In the Team Explorer, click on “Publish to GitHub”.

Enter your GitHub username and password, then click “Sign in”.

In Team Explorer, you can enter a description for the solution (or leave it blank) and decide if you want to make your repository public or private (by checking the “Private Repository” checkbox).

When you’re ready, click the “Publish” button.

After a few seconds, you should see a “Repository created successfully” message.

Go to your “Repositories” page on GitHub and you should see the new repository.

NOTE: Before you add anything to a repository, make sure you don’t have any files that contain user IDs, passwords, or any other information you want to keep private.

 

 

You can do more with GitHub, and many people prefer the command line over the Visual Studio plugin. But this should get you started.

Plus, you can now share your code with me, if you ever have a problem with your version of the program and want me to look at it.

 

To see more about what you can do with Git, especially if you want to use the command line, check out: http://gitimmersion.com/

 

Additional links for this project

Source code: https://github.com/ScottLilly/SOSCSRPG

Project plan: https://github.com/ScottLilly/SOSCSRPG/projects/1

Discord: https://discord.gg/AUYXYtH

Return to main page

Leave a Reply

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