This alias pretty prints a cute graph of commits - similar to gitk, but on the terminal. Simply add this alias to ~/.gitconfig:
[alias] graph = log --graph --all --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(bold white)— %an%C(reset)%C(bold yellow)%d%C(reset)' --abbrev-commit --date=relative
Automated bisection is a helpful way to find a broken commit in a branch, but sometimes you want to automatically check every single commit in a branch. Here is my method:
$ git rev-list start-commit..end-commit | while read id; do echo -n "$id "; git checkout -q $id; command >/dev/null 2>&1 && echo PASS || echo FAIL ; done
…where command is a command which exits with 0 on success and 1 on failure.
Typical output looks like this:
2dfae5a2966baa334d33b81f353265ba67753f60 PASS 52210ab9102a49f6be5a00d80d0987556a2cfd32 PASS 12510b5f81f2a37e9ed2a05a6ba1563465e2acfa PASS ecd155e2ca942d4d0fcc3dd03d3cb72138e5034b PASS d8c83fea3ca958b131e96ba05082c31d09ba0b9f PASS 8fc1129ed56e0427aa536df138c6cd2c320e514c FAIL b66844b345820e70bf5a3ba4119c4b74f5dca4e7 FAIL eba9adcf17398e9e63bab45b58f87ece5bdcfb13 FAIL 392c71ea68a35c886a29e58b568f961970d41eca FAIL 54940b6271c1cf2a885ea01a4d785ff95a1b1b27 FAIL 6953e740a0e8db3148425d1d64bb7cc965965315 FAIL
A variant of the command that keeps logs of all the results:
$ mkdir -p logs; git rev-list start-commit..end-commit | while read id; do echo -n "$id "; git checkout -q $id; command >logs/$id.log 2>&1 && echo PASS || echo FAIL ; done | tee id-tests.log
This will keep a record of the command's output in a series of files contained in the log/
subdirectory, and save the summary to id-tests.log
.