Git Cheatsheet

Posted on Wed, 15 Apr 2015

Tags: git, coding

It is time I let go of the crutch of using Git Extensions. There are plenty of decent git tutorials out there, and the official documentation is thorough (if not a little intimidating!) But a nice simple list of common commands would come in handy. So here we go.

Commands:

    git config --global user.name|user.email|core.editor <value>
    git init
    git clone <repository url> [<directory>]
    git remote add <repository> <repository url>

    git fetch [<repository> [<refspec>]]
    git pull [--rebase] [<repository> [<refspec>]]
    git push [--tags] [<repository> [<refspec>]]

    git add [-u] [<pathspec>]
    git commit [-m <message>]
    git branch [-f] [-u] [-d] [-r] [<branch>] [<reference>]
    git checkout [-b <branch>] [<reference>]
    git merge <reference>
    git rebase [-i] <base reference> [<head reference>]
    git cherry-pick <reference> [<reference> [<...>]]
    git stash [<message> | pop | list]

    git status
    git log [--patch] [--all] [--graph] [--decorate] [--oneline] [<pathspec>]
    gitk
    git show <reference>
    git diff [--cached] [<reference> [<reference>]]
    git difftool
    git mergetool
    git reset [--hard] <reference>
    git revert <reference>
    git tag <tag> [<reference>]
    git describe [<reference>]
    git clean -xdf
    git grep [-i] <pattern> [<pathspec>]
    git bisect [start | bad [<reference>] | good [<reference>] | reset [<reference>]]
    git reflog

References:

    <reference> = <branch> | <commit> | <tag> | HEAD | <relative reference>
    <relative reference> = <reference>^[<parent num>] | <reference>~[<ancestor num>]
    <refspec> = [+][<source>][:<destination>]
		
		
			

Categories