在Linux和Unix中执行git svn clone
后,有很多将Subversion 分支转换为Git 标记的示例。我能够使用此博客post中的步骤直到此步骤(post中的第6步)。我需要将脚本移植到PowerShell。这是Linux版本:
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
以下是我到目前为止PowerShell版本的内容:
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
答案 0 :(得分:1)
我对UNIX和git没有多少经验,所以这几乎是猜测。尝试:
& 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/$_"
}