2 ms·
Time to share my gitconfig aliases again :D lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short sw = !git ch
by bloopernova 2y ago
Time to share my gitconfig aliases again :D
lol = !git --no-pager log --graph --decorate --abbrev-commit --all --date=local -25 --pretty=short
sw = !git checkout $(git branch -a --format '%(refname:short)' | sed 's~origin/~~' | sort | uniq | fzf)
lc = !git rev-parse HEAD
rb = !git for-each-ref --sort=-committerdate refs/heads/ --format='%(refname:short) %(objectname:short) %(committerdate:format:%F)' | column -t
ws = !git show --word-diff=color --word-diff-regex='\\w+'
wd = !git diff --word-diff=color --word-diff-regex='\\w+'
fza = "!git ls-files -m -o --exclude-standard | fzf -m --print0 | xargs -0 git add"
gone = "!f() { git fetch --all --prune; git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D; }; f"
root = rev-parse --show-toplevel
oldest-ancestor = !zsh -c 'diff -u <(git rev-list --first-parent "${1:-main}") <(git rev-list --first-parent "${2:-HEAD}") | sed -ne \"s/^ //p\" | head -1' -
diverges = !sh -c 'git rev-list --boundary $1...$2 | grep "^-" | cut -c2-'
dlog = "!f() { GIT_EXTERNAL_DIFF=difft git log -p --ext-diff $@; }; f"
Some of these I don't use much, but others I use every day:
"git fza" (aliased to "ga") shows all unstaged files in fzf and you can use space to toggle them, then hitting enter finishes adding/staging them. This is great for selecting some files to stage. I use this one every day, it makes my workflow just a little better :)
"git gone" deletes local branches that don't exist in the remote.
"git lol" is a log alias.
"git oldest-ancestor brancha branchb" does what it says.
"git root" is part of an alias "gr" which runs "cd $(git root)". That takes you to the project root, and "cd -" will take you back to your previous location.
"git dlog" shows a detailed commit log.
"git lc" just shows the last commit.
Edited to add:
"git rb" shows recent branches. Piping it to "| sort -k3" will sort by date. (I really need to update that!)
"git sw" shows branches in fzf, hit enter on one and you checkout that branch.
I never use "git ws" and "git wd", I should remove those.