Git Cheat Sheet & Visual

git config --global user.name "[firstname lastname]"
git config --global user.email "[valid-email]"
git config --global color.ui auto
$ git aliases
me = !git config user.name && git config user.email
user = config user.name
email = config user.email
aliases = !git config --get-regexp 'alias.*' | colrm 1 6 | sed 's/[ ]/ = /'
s = status --short
st = status --short --branch
br = branch
co = checkout
cob = checkout -b
unstage = reset HEAD --
aa = !git add --all
ci = commit -m
amend = commit --amend
d = diff
dh = diff HEAD
ds = diff --staged
dw = diff --word-diff=color
dhw = diff --word-diff=color HEAD
dsw = diff --word-diff=color --staged
last = !git ll -1 HEAD
ls = log --abbrev-commit --date=short --pretty=format:'%C(yellow)%h %ad%Creset%Cred%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'
ll = !git ls --name-status
lg = log --oneline --decorate --all --graph
changes = !sh -c 'git ll @{1}..@{0} '
pr = !git pull -v --rebase && git changes
fc = !git ls --follow
fh = !git ls -u
locallog = log --date=local
fname = !git ls-files | grep -i

git diff –  changes in working directory.

git diff --cached – changes in staging area.

git diff HEAD – changes in working directory and staging area.

# display the full diff of each commit
git log -u

# show the history of a particular file or directory, including differences
git log -u [file]

# show all commit logs with indication of any paths that moved
git log --stat -M

# show the commits on feature that are not on master
git log master..feature
git log -p feature --not master

# show the diff of what is in feature that is not in master
git diff master…feature

# show the commits that changed file, even across renames
git log --follow [file]

# see who commited which line in a file
git annotate [file]

# show any object in Git in human-readable format
git show [SHA]

# show a graph of commits in the current branch
git log --graph

# show a graph of all commits, tags and branches in the entire repo
git log --oneline --decorate --all --graph

# show only commits whose messages include a given string (case-insensitively)
git log -i --grep search_string

# show commits that will be pushed
git log @{u}..

Also See

Source: patrickzahnd.ch

gitcheat.png
Source: github.com/mattharrison/Git-Supervisual-Cheatsheet

Leave a Comment

Your email address will not be published. Required fields are marked *