Submitting Work in Github

Working with git and github can be very confusing for first time users, so I’ve created this guide to help my GA students (and others) learn how to fork, clone, commit, and make pull requests.

This guide will assume that you’ve already successfully set up a github account and paired an SSH key with local machine.

As a review our git process/roadmap looks like this:

Step 1: Fork the Repo

Forking the repo creates a copy of it on your personal guthub account. This way you can interact with a make changes to the files in the repo without messing up the master branch.

Forking is easy, just confirm you’re on the master branch by ensuring the directory is DSI-DC-5/name_of_repo.

If your screen looks like this before you fork it, you’re doing something wrong. Navigate back to the master branch.

It should not have a github user name before the name of the repo. Only DSI-DC-5

Your screen should look like this — only DSI-DC-5 at the top.

Then click the fork button.

Select your github account image to fork it over to your repo.

When the process is finished you should now be on your forked version of the repo. We can confirm that it’s the right version because at the top will be your_github_account_name/name_of_repo and underneath it will say the repo it was forked from.

Double check that it now says your github account name.

Step 2: Clone the Repo

Now we want to download the forked repo to your local machine so that you can open and work in the files.

First, click the green clone or download button in your forked repo.

Make sure you’re in the forked repo!

Next, copy the SSH address from the dialogue.

command-c to copy!

Now, move into your terminal window and navigate to the directory where you want the new repo folder to be.

MAKE SURE THE FOLDER YOU ARE IN IS NOT A GIT REPO. DO NOT PUT A GIT REPO INSIDE ANOTHER GIT REPO.

I’m in my DC-DSI5 folder inside my documents folder. I can see there are a few other repos in this folder, but the DC-DSI5 folder is not itself a git repo.

The command to create a clone of the repo is:

git clone [the SSH address you copied earlier]

Running that command will create a new repo in the folder you’re currently in.

Step 3: Make Your Changes

Complete your lab, project, add new files, do whatever you want. They can be as big or small as you want.

Step 4: Stage and Commit the Changes

Whenever you’ve made edits or want to confirm and save your work, you should stage and commit the changes that you’ve made. You don’t have to wait until you’re ready to submit to stage, commit and push.

First, we need to tell git that we’d like to add the folder we are in to the staging area by using:

git add .

the dot tells git to stage the entire folder we are in and any subfolders.

Then we commit the changes with:

git commit -m “Put your commit message here”

Step 5: Push the Repo

Now that the changes are committed on the local machine, we need to push them to our github account. Make sure you’re in the folder you want to push and in the terminal enter:

git push

This may prompt you for your password.

You can confirm that the push was successful by looking at the files in your forked repo in github. They should reflect the changes you made.

Step 6: Make a Pull Request

This is the final step, and should be done when you’re ready to submit the final version of any lab or project. In a real development environment pull requests have a different purpose. For now, it’s just a way for us to review your work.

Make sure you’re on github page of the repo you forked and select “new pull request”:

Now, click on the big green button:

You’ll get to a page that looks like this:

You don’t have to leave any comments, just click the green button again, and then you’re done!

TL;DR

  1. Fork the repo
  2. Clone the repo
  3. Make changes
  4. Stage and commit the changes
  5. Push the changes
  6. Make a pull request

Feel free to reference this guide any time if you need a reminder on how to use git in our class!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.