【问题标题】:branch name does not conform to git standards: refs/heads/master分支名称不符合 git 标准:refs/heads/master
【发布时间】:2016-06-24 18:59:29
【问题描述】:

将 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 快速导入:转储崩溃报告 到 .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 远程存储库中显示相应文件的历史记录,但出现上述错误(如问题所述)。请提供解决方案。

【问题讨论】:

  • 这个脚本是什么?这是你正在开发的东西吗?你在使用 Unix 行尾吗?您是否正在尝试创建一个refs/heads/master\r 的品牌名称? (名称末尾带有 Windows 回车,因为行是用 \r\n 分隔的?)
  • 嗨,爱德华,我没有在名称末尾使用回车。
  • 您不必特意去做。您使用了Write-Output,它添加了一个换行符。 Windows 上的换行符是\r\n。用十六进制编辑器查看你的脚本生成的文件,你会看到它。

标签: git powershell github git-bash git-fast-import


【解决方案1】:

分支名称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

【讨论】:

    猜你喜欢
    • 2012-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 2012-02-17
    • 1970-01-01
    • 2013-12-25
    相关资源
    最近更新 更多