2

将 powershell 脚本的输出通过管道传输到 git fast import 时发生此错误。详细的错误报告如下:

D:\demo_history7 [master +4 ~0 -0 !]> .\testscript.ps1 -CSVFileName Report_Recent.csv |git fast-import fatal: 分支名称不符合 GIT 标准:refs/heads/master fast-import : 将崩溃报告转储到 .git/fast_import_crash_5968

那么这个错误的原因是什么,我该如何解决呢?

Git 快速导入无法识别 powershell 脚本的输出。这就是为什么 itz 显示错误:分支名称不符合 git 标准:refs/heads/master。我正在尝试将此脚本的输出通过管道传输到 git fast-import,以便在 git 远程存储库中显示相应文件的历史记录,但出现上述错误(如问题所述)。我的 powershell 脚本在下面的答案。请提供解决方案。


这是我的 powershell 脚本:

遍历csv文件的脚本

[CmdletBinding(SupportsShouldProcess=$true)]
Param
(
    [string] $CSVFileName 
)

# Readthe contents of the CSV file in a single shot
#Write-Output "CSV File Name is $CSVFileName"
$CSVFileContents = Import-Csv $CSVFileName

# Iterate through each file(column) in the list
foreach($CSVFile in $CSVFileContents)
{
    # Get the parameters related to each file(column)
    $FileVersion    = $CSVFile."File Version"
    $Owner          = $CSVFile.Owner
    $UpdateDate     = $CSVFile."Update Date"
    $FileName       = $CSVFile.Filename
    $Specification  = $CSVFile.Specification
    $ProjectFolder  = $CSVFile."Project Folder"

    #Get the string size of the path
    $FolderName = "D:\demo_history\" + $ProjectFolder + $FileVersion + "_" + $FileName + "\" +  $FileVersion + "_" + $FileName
    $FolderName = $FolderName.Replace("/","\")
    $count = $FolderName.length

    #Get contents of the file,display the contents  and get size
    $Filecontent = Get-Content D:\demo_history2\RMS\APP\RSS\src\com\retek\stores\transfers\states\1_SearchTransferState.java\SearchTransferState.java


    $Getitemsize = Get-Item D:\demo_history2\RMS\APP\RSS\src\com\retek\stores\transfers\states\1_SearchTransferState.java\SearchTransferState.java
    $Length = $Getitemsize.length


    $getmark=Write-Output "mark :$FileVersion"
    $Comment = "from Serena Dimensions by $Owner on $UpdateDate"
    $Sample = $ProjectFolder + $FileVersion + "_" + $FileName + "\" +  $FileVersion + "_" + $FileName
    $Sample = $Sample.Replace("/","\")
    $Mode = "M 644 inline $Sample"

    #printing output
    Write-Output "commit refs/heads/master\r\n"
    Write-Output "$getmark"
    Write-Output "committer $Owner <$UpdateDate> -62167239000 -0700"
    Write-Output "data $count"
    Write-Output "$Comment"
    Write-Output "$Mode"
    Write-Output "data $Length"
    Write-Output "$Filecontent"

}

我正在尝试将此脚本的输出通过管道传输到 git fast-import,以便在 git 远程存储库中显示相应文件的历史记录,但出现上述错误(如问题所述)。请提供解决方案。

4

1 回答 1

0

分支名称testscript.ps1包含 git 中分支名称的一些无效字符。

Git 分支名称不能包含以下字符:

- Have a path component that begins with "."

- Have a double dot ".."

- Have an ASCII control character, "~", "^", ":" or SP, anywhere

- End with a "/"

- End with ".lock"

- Contain a "\" (backslash
于 2016-03-10T05:03:41.793 回答