diff --git a/.gitconfig.inc/common.gitconfig b/.gitconfig.inc/common.gitconfig index ea7337b..0c6824c 100644 --- a/.gitconfig.inc/common.gitconfig +++ b/.gitconfig.inc/common.gitconfig @@ -19,8 +19,29 @@ [diff "ansible-vault"] textconv = ansible-vault view -[alias] - graph = log --all --graph --decorate --oneline - [credential] helper = /usr/lib/git-core/git-credential-libsecret + +[pretty] + ls = tformat:%C(yellow)%h %Cgreen%ad %Creset%s %Cblue[%an]%C(auto)%d + lsd = tformat:%>|(13)%C(yellow)%h %Cgreen%ad %Creset%s %Cblue[%an]%C(auto)%d + +[alias] + # Various aliases for showing pretty and compact git logs + ls = log --pretty=ls --decorate --date=iso + lsd = log --pretty=lsd --decorate --date=iso --all --graph + + # Compact version of git status + stat = status -s + + # Get name of remote default branch (e.g. main or master) + default-branch = !git symbolic-ref --short refs/remotes/origin/HEAD | sed 's!^origin/!!' + + # Push a new branch to origin by setting the upstream branch + pushnew = "!f() { CURRENT=$(git branch --show-current); git push -u origin ${1-$CURRENT}; }; f" + + # "back to the future": switch to default branch and pull + bttf = "!f() { DEFAULT=$(git default-branch); git switch ${1-$DEFAULT} && git pull --rebase --prune; }; f" + + # Reset HEAD to last commit, but keep files as they are + undo = reset HEAD~1 --mixed