-
-
Save nuclearglow/c48e65fe653abf268bc3bcfaa01f7c21 to your computer and use it in GitHub Desktop.
git snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# delete all local merged branches with no activity within the last week | |
for k in $(git branch --merged | sed /\*/d); do | |
if [ -z "$(git log -1 --since='1 week ago' -s $k)" ]; then | |
echo git branch -d $k | |
fi | |
done | |
# delete all merged remote branches with no activity within the last month | |
for k in $(git branch -r --merged | cut -d ' ' -f3 | sed /\*/d); do | |
if [ -z "$(git log -1 --since='1 month ago' -s $k)" ]; then | |
echo git push origin $(echo $k | sed 's/origin\//:/') | |
fi | |
done | |
# list all unmerged remote branches with no activity within the last month | |
for k in $(git branch -r --no-merged | sed /\*/d); do | |
if [ -z "$(git log -1 --since='1 month ago' -s $k)" ]; then | |
echo `git log -1 --pretty=%aN $k` $k | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment