Skip to content

Instantly share code, notes, and snippets.

@alexschwartz
Created February 16, 2011 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexschwartz/829676 to your computer and use it in GitHub Desktop.
Save alexschwartz/829676 to your computer and use it in GitHub Desktop.
GIT Knowhow - How to replace branches with tags?
## 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