Created
April 14, 2022 23:46
-
-
Save ThrowsException/dc62e7e0727c4e12ce0cacab557aff4d to your computer and use it in GitHub Desktop.
Find branches matching a pattern and tag them
This file contains 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
IFS=$'\n' | |
for b in $(git for-each-ref --format='%(objectname) %(refname:lstrip=-1)' 'refs/remotes/origin/RELEASE-2021*' 'refs/remotes/origin/RELEASE-2020*' 'refs/remotes/origin/RELEASE-2019*' --count=1); do | |
sha=$(echo "$b" | cut -d' ' -f1) | |
branch=$(echo "$b" | cut -d' ' -f2) | |
echo "$sha" | |
echo "$branch" | |
git tag "$branch" "$sha" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment