How to generate changelog of commits groupped by date, in format:
[date today]
- commit message1
- commit message2
- commit message3
...
[date day+3]
- commit message1
- commit message2
- commit message3
...
(skip this day if no commits)
[date day+1]
- commit message1
- commit message2
- commit message3
...
[date since]
- commit message1
- commit message2
- commit message3
Any git log command, or smart bash script?
Here is dirty, but working version of the script I came up with:
#!/bin/bash
# Generates changelog day by day
NEXT=$(date +%F)
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
echo [$DATE]
GIT_PAGER=cat git log --no-merges --format=" * %s" --since=$DATE --until=$NEXT
NEXT=$DATE
done
I couldn't get the accepted answer to handle today's commits as my setup didn't handle the NEXT variable properly on the first iteration. Git's log parameters will accept a time too, which removes the need for a NEXT date:
#!/bin/bash
# Generates changelog day by day
echo "CHANGELOG"
echo ----------------------
git log --no-merges --format="%cd" --date=short | sort -u -r | while read DATE ; do
echo
echo [$DATE]
GIT_PAGER=cat git log --no-merges --format=" * %s" --since="$DATE 00:00:00" --until="$DATE 24:00:00"
done
git log
has --since
and --until
, it shouldn't be hard to wrap some stuff around that.
That would require most certainly some kind of script.
A bit like this commandline-fu
for k in `git branch|perl -pe s/^..//`;do echo -e `git show --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k|head -n 1`\\t$k;done|sort -r
(not exactly what you are after but can gives you an idea nonetheless)
I know about GitStats which has also data organized by date (but not the commit messages)
Note: the git branch
part of this command is ill-fitted for scripting, as Jakub Narębski comments.
git for-each-ref
or git show-ref
are natural candidate for scripting commands, being plumbing commands.
I wrote a script in python to create a week-by-week git log.
You could easily change it to days, months, etc by changing the timedelta
https://gist.github.com/NahimNasser/4772132