在Git svn之后使用PowerShell将所有Subversion分支转换为Git标记
在Linux和Unix中执行在Git svn之后使用PowerShell将所有Subversion分支转换为Git标记,git,bash,svn,powershell,git-svn,Git,Bash,Svn,Powershell,Git Svn,在Linux和Unix中执行Git svn clone后,有许多将Subversion分支转换为Git标记的示例。我能够使用从这个博客到这个步骤的步骤(中的步骤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"; g
Git svn clone
后,有许多将Subversion分支转换为Git标记的示例。我能够使用从这个博客到这个步骤的步骤(中的步骤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
每个ref的git--format='%(refname)'refs/heads/tags|
#不确定如何替换“切割”
做{
git标记“$ref”“refs/heads/tags/$ref”;
git分支-D“标签/ref美元”;
}虽然(我对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/$_"
}
我对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/$_"
}
在Windows 10和最新的git for Windows(我使用64位)下,git Bash窗口工作得很好(我用它来代替PowerShell处理很多这类事情)。在Windows 10和最新的git for Windows(我使用64位)下,git Bash窗口工作得很好(我用它代替PowerShell处理很多这类事情)。