【发布时间】:2019-01-25 20:52:22
【问题描述】:
我如何解释这个调用“Git Clone”(实际上是使用 GitLab)的 PowerShell 脚本产生的错误。我可以克隆一个空目录并使其正常工作而不会出错吗?
$path1 = "d:\GitPath"
$path2 = "${path1}\mycompany-mygroup-nealtestautomation01-map"
$gitLabHttp = "http://git.mycompany.com/MyGroup/nealtestscriptaddedproject.git"
$gitLabHttp = "http://git.mycompany.com/MyGroup/mycompany-gwcustomers-nealtestautomation01-map.git"
rd $path2
cd $path1
git clone $gitLabHttp --local --verbose
输出:
git : Cloning into 'mycompany-mygroup-nealtestautomation01210-map'...
At D:\Scripts\GitCloneTest.ps1:7 char:1
+ git clone $gitLabHttp --local --verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Cloning into '...mation01-map'...:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
warning: --local is ignored
warning: You appear to have cloned an empty repository.
在我想使用此代码的较大脚本中,我包含以下内容:
$ErrorActionPreference = "Stop" #Special Poweshell Syntax to Stop on First Error
这样它会在第一个错误时停止。
即使我在非空项目上运行它,我也会看到类似于上面的红色和错误(取消了 --local 和 --verbose 的运行):
git : Cloning into 'xxx.yyy.CanInvToOutZZZ210.Map'...
At D:\Scripts\GitCloneTest2.ps1:5 char:1
+ git clone $gitLabHttp
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Cloning into 'E...Intl210.Map'...:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
如果我从 Windows 命令提示符运行,它运行良好并带有一些统计信息:
D:\GitGWCustomerMaps\Test2>git clone myrealurlhidden
Cloning into 'XXX.YYY.CanInvToOutZZZZ210.Map'...
remote: Counting objects: 29, done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 29 (delta 9), reused 0 (delta 0)
Unpacking objects: 100% (29/29), done.
【问题讨论】:
-
我正在尝试使用 --Quiet 标志,它可能会起作用,但不确定为什么我会收到任何需要使用该标志抑制的错误。
标签: git powershell-4.0