Skip to content

Instantly share code, notes, and snippets.

@gregilo
Last active December 11, 2025 16:12
Show Gist options
  • Select an option

  • Save gregilo/853ca0414ffea747b60c900f9a5c8339 to your computer and use it in GitHub Desktop.

Select an option

Save gregilo/853ca0414ffea747b60c900f9a5c8339 to your computer and use it in GitHub Desktop.
Git aliases for ~/.gitconfig
[alias]
delete = "!f(){ local branch_name=$1;git branch -d $branch_name && (git remote | xargs -L1 -I '{}' git push {} :$branch_name);};f" # delete a branch locally and from all remotes
rd = "!f(){ local branch_name=$1;(git remote | xargs -L1 -I '{}' git push {} :$branch_name);};f" # delete a branch from all remotes
pruneall = "!f(){ git remote | xargs -L1 git remote prune;};f" # prune all remotes
local-branches = !git branch -vv | cut -c 3- | awk '$3 !~/\\[/ { print $1 }' # list branches that exist locally but not in remotes
update = "!f(){ git fetch --all && git pruneall && git status; };f" # fetch and prune all remotes, then run `git status`
upull = !git update && git pull # fetch and prune all remotes (via update alias), then pull
plog = "log --color --graph --pretty=format:'%C(auto)%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr)%C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" # prettier `git log`
branchdiff = !git diff --unified=1 main...HEAD # diff against main
lstash = !git stash list | bat --file-name='git stash list' # list stashes with bat
fpush = !git push origin --force-with-lease
[branch]
autosetuprebase = always
[filter "lfs"]
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
[user]
name = Greg Aiello
email = greg.aiello@zapier.com
[init]
defaultBranch = main
[pull]
rebase = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment