Basics


Nice git log

alias gitlog='git log -10 --graph --date-order -C -M --pretty=format:"%C(yellow)%h%C(reset) - %C(bold green)%ad%C(reset) - %C(dim yellow)%an%C(reset) %C(bold red)>%C(reset) %C(white)%s%C(reset) %C(bold red)%d%C(reset) " --abbrev-commit --date=short'

See the real history

git reflog

Cherry-pick a commit

git cherry-pick 0dc5724

Add changes steps by steps

git add -p

Amend a commit

git commit --amend --date="Sat Mar 16 07:47:11 2019 +0000" --no-edit;

Diff branches

git diff master stage > reversion.patch

Diff file between branches

gitlog -p origin/master...master -- file.yml

Tags


List tags previous versions

git tag -l -n99 v*

Tag current version

git tag -a vX.Y.Z

Listing


Show the patch introduced by last commits

git log -p -2

Show stat about the last commits

git log --stat # --numstat --author="clobee"

List commits since xxx

git log --since=2.weeks # --before="2008-11-01"

Search the commit log (across all branches) for a given text

git log --all --grep='Build 0051'

Search the actual content of commits through a repo’s history

git grep "Build 0051" $(git rev-list --all)` 

Search the reflog itself with the -g flag (short for `—walk-reflogs
git log -g --grep='Build 0051'

Config


List configs

git config -l

Change settings

git config —global url."https://".insteadOf git://

Ignore non unix \n

git config --global core.autocrlf true

Ignore file permissions change

git config —global core.fileMode false