Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save colossus9/e967c8fec5bd8b5772ce9d489003c727 to your computer and use it in GitHub Desktop.
Save colossus9/e967c8fec5bd8b5772ce9d489003c727 to your computer and use it in GitHub Desktop.
Convert git-svn tag branches to real tags

Convert git-svn tag branches to real tags

Reference: http://gitready.com/advanced/2009/02/16/convert-git-svn-tag-branches-to-real-tags.html

This information was found in the article above and has been summarized below!

In the process of converting from Subversion to Git, tags get a bit confused and show up as branches instead once converted over. This can be pretty inconvenient, especially when using git branch since a ton of branches would show up such as tag/1.2, and so on. A little bit of scripting and Git magic can clear this up easily.

First, use git svn to convert your repository. Then, use this script to convert all of the tag branches into actual tags, and finally make sure they’re deleted properly:

git for-each-ref refs/remotes/origin/tags | cut -d / -f 5- |
while read ref
do
git tag -a "$ref" -m "Say farewell to SVN" "refs/remotes/origin/tags/$ref"
git push origin ":refs/heads/tags/$ref"
git push origin tag "$ref"
done
@LeGrosWinnie
Copy link

Strange no one commented this in 6 years.
I guess it is because no one should ever use SVN...
Why using "Say farewell to SVN" as the TAG message ? Should be at least $ref so t hat the message is the same as the tag.
Or something more pro : "Tag migrated from SVN to GIT : $ref"

Will try that soon. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment