There are lots of examples of converting Subversion branches to Git tags after performing git svn clone
in Linux and Unix. I was able to use the steps from this blog post up to this step (step 6 in the post). I need to port the script to PowerShell. Here's the Linux version:
git for-each-ref --format='%(refname)' refs/heads/tags |
cut -d / -f 4 |
while read ref
do
git tag "$ref" "refs/heads/tags/$ref";
git branch -D "tags/$ref";
done
Here's what I have so far for the PowerShell version:
git for-each-ref --format='%(refname)' refs/heads/tags |
# not sure how to replace "cut"
do {
git tag "$ref" "refs/heads/tags/$ref";
git branch -D "tags/$ref";
} while (<# I'm assuming I'm iterating a collection but I'm not sure what or how. should this be a foreach instead? #>)
done
I don't have much experience with UNIX and git, so this is pretty much guessing. Try:
& git for-each-ref --format='%(refname)' refs/heads/tags | % {
#Extract the 4th field from every line
$_.Split("/")[3]
} | % {
#Foreach value extracted in the previous loop
& git tag $_ "refs/heads/tags/$_"
& git branch -D "tags/$_"
}