Skip to content

Instantly share code, notes, and snippets.

@sarahsga
Last active May 4, 2018 12:27
Show Gist options
  • Save sarahsga/d67d568a57976874a361eac14f5f091e to your computer and use it in GitHub Desktop.
Save sarahsga/d67d568a57976874a361eac14f5f091e to your computer and use it in GitHub Desktop.
A reference to Git commands and publishing your website to Github Pages

A Guide to Git commands

Step 1

Create a local repo

git init

Step 2

Stage files to the local repo (i.e. add them to the bag)

git add .

Step 3

Commit files (i.e. tell git the files are ready to be sent)

git commit -m "anything you want to write"

Step 4

Sign Up / Login to Github

Step 5

Create a new remote repo at Github and copy the repo address

Step 6

Tell your local repo the address of the Github repo

git remote add origin <your repo address here>

Step 7

Push your commits to the remote repo

git push origin master

NOTE: The next time you make any changes to your code, you do NOT have to git init or git remote add again.


  • Any time you can check your commit history using the command git log

  • Any time you can check the status of your local repo using the command git status

  • If you get an error while running the git commit command, add your email and username using these commands:

    git config --global user.name "<your name here>"

    git config --global user.email "<your github email>

    The --global tells git to remember your name and email so you do not have to type it again when you create a new repo on the same computer.


To publish your website to Github Pages:

  • Make sure your home page is named index.html
  • Once you have pushed the code to Github, go to Github repo Settings, scroll down to Github Pages, select Master Branch from dropdown, and click save. When the page reloads, it will show you the link to your website accessible from anywhere in the world.

screen shot 2018-05-04 at 5 25 56 pm screen shot 2018-05-04 at 5 25 30 pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment