Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从PowerShell调用git命令_Git_Powershell - Fatal编程技术网

从PowerShell调用git命令

从PowerShell调用git命令,git,powershell,Git,Powershell,当我从PowerShell脚本调用git时,当我运行更复杂的命令时,我开始遇到问题: # Work fine git log # Gives error git log `git describe --tags --abbrev=0 HEAD^`..HEAD --oneline --count 错误: fatal: ambiguous argument 'git': unknown revision or path not in the working tre

当我从PowerShell脚本调用git时,当我运行更复杂的命令时,我开始遇到问题:

    # Work fine
    git log

    # Gives error
    git log `git describe --tags --abbrev=0 HEAD^`..HEAD --oneline --count
错误:

fatal: ambiguous argument 'git': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal:参数“git”不明确:未知修订或路径不在工作树中。
使用“---”将路径与修订分开,如下所示:
'吉特[…]-[…]'
从PowerShell调用这些长命令时,有没有一种封装它们的好方法?

您可以使用
$()
在字符串中执行替换以使其正常工作

git log "$(git describe --tags --abbrev=0 HEAD^)..HEAD" --oneline --count

backtick字符在PowerShell中用作转义字符,就像在Unix shell中使用反斜杠一样。

您确定内部命令“
git descripe--tags--abbrev=0 HEAD^
”本身可以工作吗?