How To Use GitHub


Make sure you read How To Use the Command Prompt first!

GitHub is an essential tool for Computer Scientists today. It is similar to Google Drive but for coders. It allows you to collaborate with others when coding. Most importantly, it allows you to manage and organize your code. There are so many additional features that GitHub offers. For our use, it hosts your websites for free without much work on your part.

Our Guide

In order to learn more about what exactly you can do with GitHub, watch this quick video created by GitHub:

Now you are ready to create your account! Visit GitHub to create your free account.

So you have now made your account. In order to make your first repository or digital storage space where you can keep your code and host it, you must navigate to the home page of GitHub and click on “Start Project”. Fill in all of the required fields. You will see a box for initializing your repository with a “README” A README is just a text file that can explain how to use your code or what is in your code. Make sure you check this box so you can get used to having a README.

You are all set up for your future projects! We are assuming you are at least a little familiar with the Command Line now that you have moved on to this tutorial!

If you have completed a project and want to save your code to GitHub and upload it straight from the command line to GitHub follow these steps:

  1. Open Command Prompt
  2. First you must copy/clone the repository you made in GitHub onto your computer.
  3. On your command line, type “git clone *url of GitHub repository*”
  4. Type “git status” to see if there were any changes. Since you just made the repository, there are no changes.
  5. Type “git add -A” to add all files changed, “git add *” to add everything, or “git add *name of specific file*” to add a file.
  6. Commit your changes. Type “git commit -m *a message to put on GitHub*”
  7. To push your files into the repository, type “git push origin master” which syncs changes from your local storage to the internet.
  8. If you have a friend who wants to retrieve your files from your GitHub, have them open the command line and type “git pull origin master”

Other GitHib Commands:

git branch *nameofbranch* --- Make a new branch

git checkout *nameofbranch* --- Switch to branch

git push origin *nameofbranch* --- push files to a branch

git pull origin *nameofbranch* --- retrieve files from a branch