Sergey Novikov
Sergey Novikov

Reputation: 4196

How I can save git commit messages to the file?

want to commit, fix errors and send changes them to the GIT repository, but the number of messages exceeds the number of rows displayed in the Unix command line so I cant read error messages. How can I save GIT commit messages to the file or possibly increase the number of lines displayed on the Unix command line?

It seems that in this GIT build uses hooks, it shows messages like:

/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

Thanks.

Upvotes: 4

Views: 3769

Answers (1)

VonC
VonC

Reputation: 1326776

For redirecting stdout and stderr for a git command, you can do:

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

(as suggested in "Trying to redirect 'git gc' output")
Or:

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

You can try and desactivate the pager to make sure to get the full log

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

See more at "How to make git log not prompt to continue?"

(This differs from the pager settings you can set for long lines, as in "git diff - handling long lines?")

Upvotes: 3

Related Questions