2012-12-31 33 views
1

我知道转义字符(`),反引号,但即使我尝试使用它的脚趾逃脱<人物,我得到错误...在PowerShell中逃离的git的日志

git log ORIG_HEAD --no-merges --date=short --pretty="format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>" > test.txt 
< was unexpected at this time. 

如何我可以像上面那样去格式化我的git日志吗?

回答

3

如果在PowerShell中v3的试试这个:

$out = git log ORIG_HEAD --% --no-merges --date=short --pretty="format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>" 
$out > test.txt 

的 - 放在%的PowerShell成不同的解析模式更适合本地的可执行文件。有关更多详细信息,请参阅此blog post

如果你还没有使用PowerShell v3的,我建议你使用从PowerShell Community Extensions echoargs看到论据git.exe从PowerShell中接收它们如:

PS> echoargs log ORIG_HEAD --no-merges --date=short --pretty="format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>" 
Arg 0 is <log> 
Arg 1 is <ORIG_HEAD> 
Arg 2 is <--no-merges> 
Arg 3 is <--date=short> 
Arg 4 is <--pretty=format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr>> 

Command line: 
"C:\Program Files (x86)\PowerShell Community Extensions\Pscx3\Pscx\Apps\EchoArgs.exe" log ORIG_HEAD --no-merges --date=short --pretty=format:<tr><td>%h</td><td>%ad</td><td>%an</td><td>%s</td></tr> 

如果你能看到PowerShell是如何传递对于exe的争论,你有一个战斗机会来弄清楚如何按摩通常涉及使用额外引号的争论。

+0

对不起,这是powershell 2 – Justin808