git alias - ghdrako/doc_snipets GitHub Wiki
List defined aliases
git config --get-regexp ^alias
git config --global alias.aliases "config --get-regexp '^alias\.'"
git aliases
git config --global alias.slog "log -n 30 --graph --pretty=format:'%C(yellow)%h%Creset %Cgreen%ad%Creset%C(blue bold)%<(10,trunc)%an%Creset %s%C(auto)%d%Creset' --date=format:'%Y-%m-%d %H:%M'"
# ===[ALIAS-START]===
#
[alias]
c = config -l
s = status -sb
l = log --pretty=oneline --abbrev-commit --abbrev=4 -25
g = log --pretty=oneline --abbrev-commit --abbrev=4 -25 --graph
rp = rev-parse --short=4
b = branch
# General purpose aliases:
# snapshot
# backup
# stat
# days
#
# Educational aliases:
# create-file
# simple-commit
# multiple-commit
# simple-loop
# simple-loop2
# clear
# branches
# Alias: snapshot
# Example:
#
# git snapshot This is my very important commit...
# git snapshot "This is my very important commit..."
#
snapshot = "!snapshot() { git add -A; git commit -m "\"$*\""; }; snapshot"
# Alias: backup
# Example:
#
# git backup This is my very important commit...
# git backup "This is my very important commit..."
#
backup = "!backup() { git snapshot "\"$*\""; git push; }; backup"
# Alias: stat
# Example:
#
# git stat
#
# Problem z find
#
stat = "!stat() { echo -n "The working directory:"; du -h -s --exclude=.git; echo -n "The git directory:"; du -h -s .git; echo -n "Commiters:"; git shortlog -s -n | wc -l; echo -n "Commits:"; git log --oneline | wc -l; }; stat"
# Alias: days
# Example:
#
# git days
#
days = "!days() { git log --pretty=format:"%cd" --date=short | uniq; }; days"
# Alias: create-file
# Example:
#
# git create-file lorem
# git create-file lorem ipsum dolor
#
create-file = "!createFile() { for name in \"$@\"; do echo $name>$name.txt; done; }; createFile"
# Alias: simple-commit
# Example:
#
# git simple-commit a
# git simple-commit a b c
#
simple-commit = "!simpleCommit() { for name in \"$@\"; do git create-file $name; git snapshot $name; done; }; simpleCommit"
# Alias: multiple-commit
# Example:
#
# git multi-commit lorem
# git multi-commit lorem ipsum dolor
#
multi-commit = "!multiCommit() { for name in \"$@\"; do git create-file $name; done; git snapshot \"$*\"; }; multiCommit"
# Alias: simple-loop
# Example:
#
# git simple-loop lorem 5
#
simple-loop = "!simpleLoop() { NAME=$1; i="1"; while [ $i -le $2 ]; do git simple-commit $NAME$i; i=$[$i+1]; done; }; simpleLoop"
# Alias: simple-loop2
# Example:
#
# git simple-loop2 lorem 7 13
#
simple-loop2 = "!simpleLoop2() { NAME=$1; i=$2; while [ $i -le $3 ]; do git simple-commit $NAME$i; i=$[$i+1]; done; }; simpleLoop2"
# Alias: clear
# Example:
#
# git clear
#
clear = "!clear() { rm *.txt; git snapshot "Cleared!"; }; clear"
# Alias: branches
# Example:
#
# git branches lorem ipsum dolor
#
branches = "!branches() { for name in \"$@\"; do git branch $name; done; }; branches"
#
# ===[ALIAS-STOP]===