2012-12-31 32 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