GIT Tricks - mittman/timeme GitHub Wiki

  1. summary [stupid] git tricks

Table of Contents

Recursively change commit author

List current branch

$ git branch
* master

List committers

$ git shortlog -s

Rewrite function

git-chauthor() { git filter-branch --commit-filter '
if [ "$GIT_AUTHOR_EMAIL" = "$1" ]; then GIT_AUTHOR_NAME="$2"; 
GIT_AUTHOR_EMAIL="$3"; git commit-tree "$@"; 
else git commit-tree "$@"; fi' HEAD; }

Rewrite history

$ git-chauthor <old email address> <new author name> <new email address>

Ref 'refs/heads/master' was rewritten

List committers

$ git shortlog -s

Push changes

$ git push --force --all

Print git commits to PDF

Output git commits to file

$ git --no-pager log 
--pretty="format:[START commit][author=%an][time=%at][message=%s][hash=%H]" 
--shortstat > /dev/shm/git-data.txt

Convert to HTML

$ python2 gitbook.py TimeMe /dev/shm/git-data.txt /dev/shm/git-book.html
Note: depends on python2-jinja module

Convert to PDF

$ wkhtmltopdf -s Letter -b /dev/shm/git-book.html /dev/shm/git-book.pdf

Generate git statistics

gitstats <git></git> <output></output>

$ gitstats . /dev/shm/stats

convert tables to blue

$ sed &amp;&#35;45&#59;i 
&amp;&#35;45&#59;e &amp;&#35;39&#59;s/rgb([[:digit:]]/rgb(/g&amp;&#35;39&#59; 
&amp;&#35;45&#59;e &amp;&#35;39&#59;s/, [[:digit:]]&amp;&#35;42&#59;, [[:digit:]]&amp;&#35;42&#59;)/, 116, 205)/g&amp;&#35;39&#59; 
/dev/shm/stats/activity.html

recolor graphs to blue

$ cd /dev/shm/stats&amp;&#35;59&#59;
$ IFS&amp;&#35;61&#59;$(echo &amp;&#35;45&#59;en &amp;quot&#59;\n\b&amp;quot&#59;)&amp;&#35;59&#59;
$ for i in $(ls &amp;quot&#59;$@&amp;quot&#59;)&amp;&#35;59&#59;
do
  convert &amp;&#35;45&#59;fill blue &amp;&#35;45&#59;opaque red &amp;quot&#59;$i&amp;quot&#59; &amp;quot&#59;_$i&amp;quot&#59; &amp;amp&#59;&amp;amp&#59; mv &amp;quot&#59;_$i&amp;quot&#59; &amp;quot&#59;$i&amp;quot&#59;&amp;&#35;59&#59;
done&amp;&#35;59&#59;

Convert to PDF

$ cd /dev/shm/stats
$ wkhtmltopdf &amp;&#35;45&#59;s Letter &amp;&#35;45&#59;b 
index.html activity.html authors.html files.html 
lines.html tags.html /dev/shm/output.pdf
⚠️ **GitHub.com Fallback** ⚠️