voltas voltas - 1 year ago 101
Bash Question

Organize the git log format

I'm trying to organize the git log output between the starting and ending commit IDs in the below fashion

user: <user name>
commit id : <sha1>
date : <check-in date>
description : <check-in description/message>
file_name : <files associated>
2nd set
3rd set
so on

I went thru git documentation and framed the following command but not getting the output I expected. (Pls. excuse my feeble attempt here, new to git :( )

git log --pretty=format:"%cn%h%cd%B" --name-only 8ce980e...99214db~%n

Any suggestion on how to organize the log, to the above mentioned format. Thanks

Answer Source
LOG_LINE_SEPARATOR=$(for i in `seq 60`; do echo -n "-"; done); git log --pretty="format:$LOG_LINE_SEPARATOR%nuser: %an%ncommit id: %H%ndate: %aD%ndescription: %B%nfile name: " --name-only

LOG_LINE_SEPARATOR=$(for i in `seq 60`; do echo -n "-"; done); generates a sequence of - characters used to separate entries.

Full list of placeholders may be found here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download