Last active
August 23, 2024 04:54
-
-
Save jcayzac/a7727db5834589fae38a80972d8ea757 to your computer and use it in GitHub Desktop.
Git subcommand for sync'ing a working copy's branches and tags
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
#!/usr/bin/env bash | |
set -eu -o pipefail | |
echo "Pruning local tracking branches that don't exist anymore on the remote…" | |
git update | |
echo "Pruning local branches that have been merged…" | |
echo "Note: top-level branches are considered protected, only branches with a / in their name will be deleted." | |
git branch --format '%(refname:lstrip=2)' --merged | grep '/' || true | xargs -n 1 git branch -d | |
echo "Synchronizing tags with remote…" | |
git tag -l | xargs -n 1 git tag -d && git fetch --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment