Show Menu

Working Directory -> git add -> staging -> git commit -> local -> git push -> remote

Git Status

Displays the state of the working directory and the staging area
Files in the working directory:
listed under "­Changes not staged for commit­"
Files in the staging area:
Listed under "­Changes to be commit­ted­"
Files in the local repo:
Nothing to commit (working directory clean)

Git Diagram

Working Directory <-> Staging

Working Directory -> git add -> Staging
Working Directory <- git checko­ut/­merge <- Staging
Working Directory <- git diff -> Staging

Making changes

Add file to stage
git add fileName
Add all files to stage
git add .
Add changes in specific file
git add -p <fi­le>

Evaluate changes

diff of what is changed but not staged
git diff --


List all branches
git branch
Add a branch
git branch NameOf­New­Branch
Switch to specified branch in working directory
git checkout -- BranchName
Join specified [from name] branch into your current branch (the one you are on currently)
git merge -- fromName
show all commits in the current branch’s history
git log

Staging <-> Local Repo

Staging -> git commit -> Local Repo
Staging <- git reset <- Local Repo
Staging <- git diff --staged -> Local Repo
Staging <- git checkout HEAD filename <- Local Repo
(git checkout HEAD filename command rolls back all changes that have been made to filename since the last commit)

Committing to remote

Move all staged files to git remote repo
git commit -m 'message'
Move all staged files to git remote repo
git commit -am 'message'

Reverting changes

Unstage a file while retaining the changes in working directory
git reset fileName
diff of what is staged but not yet commited
git diff --staged

Start Project

Create Project
git init direct­oryName
Download remote repo
git cline ulrName

local <-> remote

local -> git push -> remote
local <- git pull/fetch <- remote

Remote to local

Git fetch
Bring down all branches from Git remote
Git pull
Fetch and merge commits from remote branch

Local to remote

git push
Transmit local branch commits to the remote repository branch

Checking the Status of a Git Repo

Git status:
Helps - show the user the files they would commit by running git commit and the files they could commit by running git add before running git commit

Git diff filename:
Displays the differ­ences between the working directory and the staging area in one specific file
git diff hello.txt

Git log:
Shows all the commit logs for a project -
A 40-cha­racter code, called a SHA, that uniquely identifies the commit.
The commit author
The date and time of the commit
The commit message


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Bash Dev Cheat Sheet
          Linux Cheat Sheet
          Common Commands Cheat Sheet

          More Cheat Sheets by datamansam