我正在尝试创建别名,git commit并将消息记录到单独的文本文件中.但是,如果git commit返回"nothing to commit (working directory clean)",则不应将任何内容记录到单独的文件中.
这是我的代码.该git commit别名作品; 输出到文件的工作原理.但是,无论返回什么内容,它都会记录消息git commit.
function git-commit-and-log($msg)
{
$q = git commit -a -m $msg
$q
if ($q –notcontains "nothing to commit") {
$msg | Out-File w:\log.txt -Append
}
}
Set-Alias -Name gcomm -Value git-commit-and-log
Run Code Online (Sandbox Code Playgroud)
我正在使用PowerShell 3.