Skip to content

Commit 4b540d7

Browse files
committed
Add prunegone alias to README and create corresponding script
1 parent df472cd commit 4b540d7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ GitHub Repo : https://github.com/Magnus167/git-aliases
1717
cop = "!f() { git checkout $1 && git pull; }; f"
1818
cob = checkout -b
1919
branchr = branch --sort=-committerdate
20+
prunegone = !git fetch --prune && git branch -vv | awk '/: gone]/{print $1}' | xargs -r git branch -d
21+
2022
pr = "!f() { BRANCH=$(git branch --show-current); REPOURL=$(git config --get remote.origin.url); python ~/git-aliases/python/getpr.py $REPOURL $BRANCH; }; f"
2123
co-pr = "!f() { REPOURL=$(git config --get remote.origin.url); BRANCH=$(python ~/git-aliases/python/checkoutpr.py $REPOURL $1); git checkout $BRANCH; git pull; }; f"
2224
```

aliases/prunegone.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# # prunegone
2+
# ## Usage:
3+
# ```bash
4+
# git prunegone
5+
# ```
6+
# ## Intended use
7+
# Use this alias to delete all branches that are gone on the remote.
8+
# It does not delete branches that are not gone on the remote, or are
9+
# not on the remote at all.
10+
#
11+
# Running this alias executes:
12+
# ```bash
13+
# git fetch --prune
14+
# git branch -vv | awk "/: gone]/{print \$1}" | xargs -r git branch -d
15+
# ```
16+
17+
git config --global alias.prunegone '!git fetch --prune && git branch -vv | awk "/: gone]/{print \$1}" | xargs -r git branch -d'

0 commit comments

Comments
 (0)