【发布时间】:2019-12-08 06:42:24
【问题描述】:
我有一个简单的 PowerShell 脚本,可以让文件夹与它的 git 存储库保持同步。
Param(
[Parameter(Mandatory = $true)][string]$branch,
[string]$location,
[int]$depth
)
Get-ChildItem -Recurse -Directory -Depth $depth -Filter _$branch -Name -Path $location |
ForEach-Object {
Write-Output "`n$("{0:MM/dd/yy} {0:HH:mm:ss}" -f (Get-Date)): Getting latest from $location$_"
git -C $location$_ pull
} *>> logs\$branch.log
当存储库已经是最新的时,它可以正常工作。但是,如果不是,则输出如下:
07/29/19 14:47:27:从 somepath 获取最新信息 git:来自 https://gitlab.com/someplace 在某个地方\UpdateBranch.ps1:10 char:5 + git -C $location$_ 拉 + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (来自 https://gi...n/somerepo:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError b34e5d0..3ec9561 开发 -> 起源/开发 b6d33b1..65fb520 特征/特征1 -> 原点/特征/特征1 * [新分支] feature/feature2 -> origin/feature/feature2 c3fe1c9..9553b72 主 -> 原点/主 更新 b34e5d0..3ec9561 快进 样式表.scss | 4++-- ... 6 个文件更改,11 个插入(+),10 个删除(-)好像做了更新,但也输出错误。
【问题讨论】:
-
你认为那里的错误是什么? FF 运行良好(获取输出也是如此)。
-
@eftshift0 从第 3 行开始。相当肯定
FullyQualifiedErrorId : NativeCommandError不应该在那里。
标签: git powershell