【发布时间】:2019-10-03 18:10:47
【问题描述】:
git 命令git reset HEAD~ 将撤消最后一次提交。但是,当我尝试使用System.Diagnostics.ProcessStartInfo 在 PowerShell 中运行命令时,该进程就挂起。
我认为它与波浪号 (~) 标记有关,因为我试图用反斜杠转义它,并且命令不再挂起。但它也没有奏效。它只是默默地失败了。
这是脚本:
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = "C:\Program Files\Git\cmd\git.exe"
$pinfo.Arguments = "reset HEAD~"
$pinfo.WorkingDirectory = "C:\GitRepo"
$pinfo.RedirectStandardError = $true
$pinfo.RedirectStandardOutput = $true
$pinfo.UseShellExecute = $false
$pinfo.CreateNoWindow = $true
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$p.WaitForExit()
【问题讨论】:
标签: git powershell escaping freeze tilde