Open source
  • Bandwidth benchmark
  • TouchWidgets UI lib
  • Diviner big number math
  • Documentation
  • x86 instructions ref
  • GIT quick ref
  • GPG quick ref
  • Avoid Ubuntu
  • Android malware risks
  • iOS malware risks
  • OS/X security tips
  • Who blocks Tor
  • Software engineering
  • BASH aliases
  • I.B. pro/con
  • Nutrition
  • Other apps
  • Contact
    1 at zsmith dot co

    GIT Quick Reference

    Revision 3
    © by
    All rights reserved.

    To add a file git add fileName
    To commit some changes locally git commit
    To push changes to the master branch git push origin master
    To push changes to a different remote branch git push origin branchName
    To merge changes on master from some other person git pull origin master
    To get the current status of local files git status
    To get the change log for the branch git log
    To get the change log for one file git log -- fileName
    To add a tag git tag tagName
    To push tags to the remote server git push --tags
    To save local changes git stash
    To recover and merge local changes git stash pop
    To change branches git checkout branchName
    To create a new branch git checkout -b newBranchName


    Files can be in 4 different places.
    1. Working directory.
    2. Staging.
    3. History.
    4. On a remote server.
    The first three locations are on your machine. Git does not have to be used with a remote server.

    Use "git add" to move a file from working directory to staging. Use "git commit" to move a file from staging into history. Use "git push" to move a file from history to the remote server.


    Files can be in 5 different states.
    • Untracked.
    • Unmodified tracked.
    • Modified tracked.
    • Staged tracked. (Committed)
    • Ignored.
    The typical daily work process is:
    Use "git add" to move your changes from working directory to staging.
    Use "git commit" to move your changes from staging into history.
    Use "git pull" to fetch and merge others' changes into your copy.
    Use "git push" to send the merged changes from history to the  remote server.

    Check out/in

    • "git clone" does your initial checkout of a preexisting branch.
    • "git fetch" fetches remote changes but does not do a merge.
    • "git pull" fetches remote changes and then does merges those with your committed changes.
    • "git push" move changes from history to the remote server.


    • "git diff" compares working to staged.
    • "git diff --staged" compares staged to history.
    • "git diff HEAD" compares working to both staged and history.
    • "git diff -w" ignores whitespace differences.
    • "git diff branch1..branch2" prints differences between two branches.


    • "git log -- file" prints changes to one file.
    • "git log -S string" searches the log for a string.
    • "git log --decorate --graph" pretty prints the log.
    • "git log -G regex"


    • "git branch" shows all branches.
    • "git branch -r" shows remote branches.
    • "git branch name" creates a new branch.
    • "git branch name hashcode" creates a new branch at a specific checkin.
    • "git branch -m oldBranchName newBranchName" renames a branch.
    • "git checkout branch" switches to a branch.
    • "git checkout -b branch" creates and switches to specified branch.
    • "git branch -d branch" deletes a branch.
    • "git branch -D branch" forces the deletion of a branch.
    • "git remote add branchName URL" connects your branch to the remote server URL.
    • "git push -u origin branchName" sends your branch to the remove server.

    File operations

    • "git mv file1 file2" moves/renames a file within git.
    • "git rm file" removes both working and staged copies of a file.
    • "git ignore file" tells git to never check in a file.


    • "git add" marks a manually merged file as fixed.
    Automatic merges sometimes introduce errors.


    • "git submodule add URL" brings in a git repo.
    • "git submodule update --init --recursive" loads associated submodules recursively.
    • "git clone --recurse submodules URL" does what you think.

    Stash stack

    • "git stash" saves current changes
    • "git stash pop" restores and merges stashed changes
    Stashing is useful for doing manual merges.


    There are three levels of resets:
    • "git reset --soft"
    • "git reset --mixed" (default)
    • "git reset --hard"
    "git reset HEAD file" undoes staged changes to a file.

    "git reset --hard HEAD~1; git push -f" may undo the last push to the server.

    Useful shell aliases

    • alias S="git status"
    • alias C="git commit -m "
    • alias A="git add "
    • alias UM="git pull origin master"
    • alias PM="git push origin master"

    © Zack Smith