Skip to main content

Github Desktop Cheatsheet

I want to get code from a repo onto my computer (Cloning)

Follow these steps if you need to get code from a Github repository onto your computer (for example to complete your coursework).

info

Github Desktop might look a bit different if are cloning the first repository on your computer.

Video

Instructions

  1. Open the repository on Github in your browser
    • For most of your coursework this will likely be https://github.com/CodeYourFuture/COURSEWORK_REPO_NAME
  2. Click the "Code" button, which opens a menu:

Code menu

  1. Copy the URL (Pro Tip: you can click the clipboard icon on the right to copy automatically!)
  2. Open Github Desktop, and click on the File menu and then click Clone Repository:

File menu

  1. In the Clone Repository modal, make sure you are on the URL tab. Then paste the URL that you copied before into the "URL or username/repository" input:

Add repo button

  1. The "Local Path" input controls where the files will end up on your computer. You can probably leave it as the default
  2. Click the Clone button, and wait until it has finished cloning

Congrats! You have successfully cloned a repository from Github! 🎉

I want to open Visual Studio Code with code from my repository

Follow these steps if you already have the repository on your computer and you want to edit the files.

  1. In the menubar, click the Repository option
  2. Then click the Open in Visual Studio Code option:

Open in Visual Studio Code option

Visual Studio Code will now open with the code from the repository.

I want to save my code to the repository (Committing)

Follow these steps if you have edited some code, and want to update the repository with your changes.

Video

Instructions

  1. Open Github Desktop and ensure you are in the correct Current Repository
  2. A diff showing the changes that you made is shown (lines with a green background were added, and lines with a red background were removed):

Showing a diff

  1. Click on the files in the sidebar to see different files. Make sure that you're only changing files that you meant to change
  2. Once you're happy with your change, fill out the input boxes in the bottom left to add a commit message:

Adding a commit message

  1. Click the "Commit to main" button

You just committed your code to the repository! 🎉

You should now see "No local changes". You can now make more changes to the repository (and more commits), or you can push your existing commits.

I want to send my code to volunteers (Pushing)

Follow these steps if you have committed some code, and want to send it to the volunteers.

Video

Instructions

  1. Open Github Desktop and ensure you are in the correct Current Repository
  2. Click the "Push origin" button at the top:

Push origin

The next steps are different depending on whether this is the first time you have pushed this repository to Github. If this is the first time you have pushed this repository, follow steps 3, 4 and 5 below. If not, you can skip those steps.

  1. If this is the first time you have pushed this repository, a message pops up asking if you want to fork this repository. Click the Fork this Repository button:

Fork this repository

  1. A new message then pops up asking how you are planning to use the fork. Click the "To contribute to the parent project" option, then click Continue:

Contribute to the parent project

  1. Click the "Push origin" button again

  2. In the menubar, click the Branch > Show Pull Request option:

Contribute to the parent project

  1. This will open a tab in your browser. Click the "Create pull request" button on the right:

Contribute to the parent project

  1. Fill out the Pull Request title (it is helpful to include your city, name and which week the coursework is for):

Contribute to the parent project

  1. Click the "Create pull request" button

Congrats! You just created a Pull Request on Github! 🎉

The volunteers will now be able to review your code and give feedback!

TODO

  • Glossary
  • Tips on writing a good commit message?
  • Tips on understanding a diff?