GitHub Intermediate

Leveraging Git and GitHub from the command line

Please note: This class and curriculum have now become a part of the two day GitHub for Developers course.

This curriculum will be your companion to the GitHub Intermediate class taught by the GitHub Training Team and other educational groups. In this course you’ll learn how to extensively leverage Git and GitHub from the command line.

Git repository creation at the command line

Git Configuration

GitHub for Mac Advanced Preferences

Some configuration options have become defaults over time:

# Enable use of color in output for Git versions older than 1.8.x
$ git config --[scope] color.ui auto
Line endings

The line ending setting is one of the most common settings users choose to set early in their use of Git. Some Git configuration options, like this one, affect platform-targeted behavior:

# Set line endings to LF for Mac and Linux
$ git config --[scope] core.autocrlf input
# Set line endings to CRLF for Windows
$ git config --[scope] core.autocrlf true
# List all inherited configuration
$ git config --list

Start a repository

Versioning content

Three stage thinking


Commit versions


Commit DAG



Review pending modifications

Git advocates precision in each commit’s contents and commit message. This is facilitated by easy reviewing of in-flight changes prior to describing them and making them permanent.


The simplest invocation of diff is the most common. It displays the difference of the files that have been modified.

$ git diff

Git also creates a distinction between what is modified and unselected and what has been staged for commit. A single diff option switch allows for the inspection of each of these two groups of changes.

$ git diff --staged

The default line-level difference indicators are sometimes insufficient for prose and small variable-name changes. There is, however, an option to instruct Git to perform and highlight intra-line comparisons.

# Highlight word changes on lines
$ git diff --color-words

Diff, by default, performs comparisons on all modified files. If inspection of just a subset is called for, diff accepts a precise or wildcard-ed filename or path as an option.

# By specific file
$ git diff [file-path]


Review historical changes

Git can look back at the history of each commit to see when a change took place, who made the change, or what the change contained.

$ git log

Some simple option flag additions to the log command can make the output more concise.

# Simple commit summaries
$ git log --oneline

And if displaying the full contents of the change and word-level comparisons are helpful, there are option switches for that too.

# Option switches common with `diff`
$ git log --patch --color-words


Local workflows

Organizing history:


Distributed repositories

Acquiring a repo:

$ git clone [repository-url]

Remote workflows


Shortcuts and custom commands

File lifecycle


Undoing changes

Recovering anything

Table of Contents