Lab
Last updated
Was this helpful?
Last updated
Was this helpful?
Setting up a repository for your in-class work
Important Note: We'll be creating separate Git repositories for Homework and each Project. Make sure they are separate folders, so that no git repository folder is inside another git folder. That can get very confusing.
You should already have a folder with some class work in it. It might be called classwork
, or you might have given it a different name. If not, you can start fresh, that's ok.
In the top folder run:
git init
- This creates a new git repository in this folder (and includes every folder below it)
Run git status
- it will show you what files are not yet added to the git repo (all of them)
Run git add <filename or folder>
to add specific files and folders to the list of things to commit
Run git status
to see which ones are ready to be added (in green) and which ones are not (in red)
Run git commit
to commit all the green files - give the commit a message and save.
Run git log
to see your commit history
Set up SSH keys:
Go to (create account if you don't already have one: )
Set up SSH keys
If you already have a ~/.ssh/id_rsa
file you can skip this.
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ''
ssh-add ~/.ssh/id_rsa
Copy your SSH public key: pbcopy < ~/.ssh/id_rsa.pub
ONLY COPY THE .pub
one, the other one is private and you should treat it like a password.
Go to and click "Add SSH key"
Paste it in.
In the GitHub web interface, use the +
in the top-right to create a new repository.
There's a bunch of settings for your new repository, choose:
No template
Public
Leave both checkboxes under "Initialize this repository with:" un-checked.
Create the repo and then follow the instructions it shows you to add a remote to your existing Git repo.
Check that all your files are there. :)
When looking at your repository on the website, there's a "Code" button which is for making a local clone of the repository. Find the SSH option and copy the command.
With your terminal in an entirely separate folder that is not inside any other git folder paste the command and run it.
git clone <address>
You now have two copies of your repository. Let's see if we can make a change in one and then sync that change to the other copy.
Add a new file in one of your repo copies.
Use git status
, git add
and git commit
to make a commit including that change.
Use git push
to push it to GitHub (check the change is there on GitHub)
Go to the other repo folder and use git pull
to update with that change too.