| Some of my git aliases might be useful to folks here (I post them from time to time on git threads) 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
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. I just saw in this thread that git remote prune origin might do the same thing, I need to test that. "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. "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. |