Skip to content

Commit 7492fff

Browse files
committed
Support main branch names in git aliases
1 parent c243d55 commit 7492fff

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

rc/gitconfig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@
4242
[alias]
4343
acp = "!f() { git add . && git commit -m \"$*\" && git push; }; f"
4444
branches = !git branch -vv
45-
cleanup = !"git fetch -p && git branch --merged origin/master | grep -vE '^\\*|master' | xargs -r git branch -d"
45+
cleanup = "!f() { \
46+
BASE=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'); \
47+
git fetch -p && \
48+
git branch --merged origin/$BASE | grep -vE \"^\\*|$BASE\" | xargs -r git branch -d; \
49+
}; f"
4650
deltag = !git tag -d $1 && git push origin :refs/tags/$1
4751
jeff = !git diff --ignore-space-at-eol -b -w --ignore-blank-lines
4852
lg = !git --no-pager log --reverse --pretty='%C(yellow)%h %C(bold blue)%<(15,trunc)%an%Creset %Cgreen%ad%Creset %s%C(auto)%d%Creset' --date=format:'%Y/%m/%d %H:%M' -n32

0 commit comments

Comments
 (0)