如何将git提交消息保存到文件中?

时间:2013-12-16 07:02:27

标签: git unix

想要提交,修复错误并将更改发送到GIT存储库,但是消息数量超过了Unix命令行中显示的行数,因此我无法读取错误消息。如何将GIT提交消息保存到文件中,或者可能增加Unix命令行上显示的行数?

似乎在这个GIT构建中使用了钩子,它显示了如下消息:

/usr/local/scripts/act check test-file --file-www/htdocs/doms/netflow/scripts/read.php --verbose
Logging output to toLogs
[ OK ]   php lint for /www/htdocs/doms/netflow/scripts/read.php - no errors
[ OK ]   code-wrangler audit-php for /www/htdocs/doms/netflow/scripts/read.php - no errors
[ OK ]   No Errors Detected

感谢。

1 个答案:

答案 0 :(得分:2)

对于git命令重定向stdout和stderr,你可以这样做:

git commit -m "your message" 2>&1 | cat >> log &

(如“Trying to redirect 'git gc' output”中所述)
或者:

script -q -c 'git commit -m "your message"' > log
script -q -c 'git commit -m "your message"' | sed 's/\r.*//g' > log

您可以尝试停用寻呼机以确保获取完整日志

 git --no-pager log --decorate=short --pretty=oneline > alog.txt
 # or
 GIT_PAGER="cut -c 1-${COLUMNS-80}" git log

点击“How to make git log not prompt to continue?

了解详情

(这与您可以为长行设置的寻呼机设置不同,例如“git diff - handling long lines?”)