Show Menu
Cheatography

GitHub Cheat Sheet (DRAFT) by

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Switch Branches

git checkout <br­anc­h>
switches to branch
git checkout -b <br­anc­h>
create a new branch that forks off of current branch
git branch -a
see all branches
git stash
store unstaged changes
git stash pop
restore unstaged changes

Commit Changes

git status
see current status of documents within git repo
git log
see past commits
git diff <fi­le>
see changes made to specified file
git add (-u | <fi­les­>)
stage changed files (
-u
adds all tracked files)
git commit -m "­<me­ssa­ge>­"
commit files
git push origin <branch name>
push commits to remote repo

Undo Git Commands

git reset --hard
revert changes back to previous commit
git reset --hard HEAD~3
go back 3 commits
git commit --amend
change most recent commit message
git push origin <branch name> --force
change most recent commit message after a push
 

Rebase

1
git checkout master
2
git pull
 
to get the most recent version of master
3
git checkout <br­anc­h>
4
git rebase master
Fix any merge conflicts
 
git add <fi­les>
 
git rebase --continue
5
git push origin <br­anc­h> (--force, if there were merge conflicts)

Update Git for a Project

1
cd to the folder that contains
bDocs-­Master
2
git pull (if already on correct branch)
 
most likely will need to do a
git stash
to store changes to config­/app.r
3
git pull
4
git stash pop