Convert All Subversion Branches to Git Tags Using PowerShell After a git svn

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 sorta understand what’s going on but I’m not that familiar with Linux scripts (bash?) and I’m still new to PowerShell. I need to port the script to PowerShell but I’m having difficulty completing it because of my noobness. 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:

  • Calling external commands when switching branches
  • Git - for a single file, number of times each line changed
  • Single login to SSH, share the session to run git-receive-pack and remotely run some other commands
  • What are the dashes in git? Such as: -a -b -p
  • How can you block git commits from invalid users?
  • Bash Script -exec syntax
  • 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
    

  • GIT installation after homebrew reinstall in OSX Yosemite
  • Git commits showing up in log but not in Github
  • How to change owner after executing post-update hook?
  • Trigger a Jenkins Build based on Commit Author?
  • Portable gcc executable?
  • How do I host my website on github
  • One Solution collect form web for “Convert All Subversion Branches to Git Tags Using PowerShell After a git svn”

    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/$_"
    }
    
    Git Baby is a git and github fan, let's start git clone.