Created
February 16, 2011 16:35
-
-
Save alexschwartz/829676 to your computer and use it in GitHub Desktop.
GIT Knowhow - How to replace branches with 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
## Given a git repo with at least one branch (for example "tags/A") | |
## which should be transformed into a tag | |
for t in `git branch -r | grep tags | perl -pi -e "s/origin\///"`; do | |
echo ============================ $t ; | |
REV=`git log -1 --pretty=%h origin/$t`; | |
COMMENT=`git log -1 --pretty=%s origin/$t`; | |
TAG=`echo $t | cut -d'/' -f2`; | |
echo $t .. $REV .. $COMMENT .. $TAG; | |
git tag -a $TAG -m "$COMMENT" $REV; | |
git push origin :refs/heads/$t; | |
done | |
git push --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment