Review the Local GitHub Flow in the Command Line

Now that you are a collaborator, use the local workflow we just learned to make changes to this repository. This exercise is a bit of a review, but if you need assistance with any of the required steps, more detailed directions are available in I need a refresher below! Good luck!

gif of following the directions below

  1. Clone the repository to your local machine.
  2. Create a new branch in the cloned repository. Something like yourUsername-add-page is a perfect branch name.
  3. Checkout to your new branch.
  4. Create a file in the _pages directory titled: <username>.yaml. Replace <username> with your GitHub username.
  5. Enter the following content into your file:

    githubHandle: <YOUR-USERNAME>
    pageUrl: <YOUR-USERNAME>
    timestamp: <TODAYS-DATE-YYYY-MM-DD>
    • Replace <YOUR-USERNAME> with your GitHub username.
    • Replace <YOUR-USERNAME> with your web site’s URL (leave out the https).
    • Replace <TODAYS-DATE-YYYY-MM-DD> with today’s date using a 4 digit year, 2 digit month, and 2 digit day format.
  6. Commit your changes.
  7. Ensure your work was committed.

     git status
I need a refresher

Clone the Repository

  1. Navigate to your repository’s Code tab.
  2. Click Clone or download.
  3. Copy the URL provided.
  4. Open your command line or Terminal application and enter the directory where you would like to copy the repository. This can be anywhere in your local file system, like your home directory. For example:

     cd ~/

    Pro Tip: Type cd .. to go up one level from your website repository.

  5. Clone the repository by replacing <URL> with clone URL you copied in the previous step. The repository will be cloned into a new directory in this location.

     git clone <URL>
  6. Navigate into the directory of the repository you just created. Replace with your own repository's name.


Create a Branch

  1. Create a branch. Replace <BRANCH-NAME> with your branch’s name.

     git checkout -b <BRANCH-NAME>

Add the File

  1. In your favorite text editor, add a file to the _pages directory. Include your GitHub handle in the filename: username.yaml.
  2. Enter the following content into your file:

     githubHandle: <YOUR-USERNAME>
     pageUrl: <YOUR-USERNAME>
     timestamp: <TODAYS-DATE-YYYY-MM-DD>
  3. Ensure you’ve replaced <YOUR-USERNAME> with your GitHub Username, <YOUR-USERNAME> with the URL to your site, and TODAYS-DATE-YYYY-MM-DD with today’s date, using a 4-digit year, 2-digit month, and 2-digit day. For example, if today is October 17, 2016, you would enter: 2016-10-17.

Commit the Changes

  1. Go back to the command line and type:

    git status
  2. Add your file to the staging area:

    git add FILENAME
  3. Type:

    git status
  4. Commit your changes:

    git commit -m "describe your changes"
  5. Ensure your work was committed:

    git status
Tell me why

Reviewing the GitHub Flow

Now you will see all of the great pages that have been made by others, and share your page with the world in our class repository! To do that, we’ll follow the same 5 steps of the GitHub workflow, but on the class repository.

Remember, the 5 steps are:

  1. Create a branch :arrow_left: (This section deals with this step.)
  2. Make commits :arrow_left: (And this one.)
  3. Open a Pull Request
  4. Collaborate, and make more commits
  5. Merge the Pull Request

You’ve followed this workflow twice so far; once in the Introduction to GitHub course, and once in this course.

Stuck? Open an issue in the repository for this class and mention @githubteacher for help from one of the GitHub trainers!