I am trying to get commits that exist in branch A, but does not exist in branch B. I thought these two commands will give me the same result, but they don't.
git rev-list A ^B --no-merges | wc -l
git log A ^B --no-merges | wc -l
The first one gives me 370, while log
returns 8000. What is the difference between these two?
The output from git rev-list
is (by default at least) just the commit hashes:
$ git rev-list HEAD^..HEAD
e3a80781f5932f5fea12a49eb06f3ade4ed8945c
The output from git log
is, by default, rather a lot more verbose:
$ git log HEAD^..HEAD
commit e3a80781f5932f5fea12a49eb06f3ade4ed8945c
Author: Junio C Hamano <[email protected]>
Date: Wed Feb 21 12:45:35 2018 -0800
Fourth batch for 2.17
The first is one line (for one commit), the second is five lines (for a commit whose log message is just one line long). The minimum ratio is therefore five-to-1, and:
$ echo 10k 8000 370 / p | dc
21.6216216216
shows that your ratio is almost 22-to-1, suggesting that most of your log messages are about 18 lines long on average.
Basicly git git log
is the same like git rev-list, but with a special format.
in both git log
and git rev-list
you can specify the format.
I made an alias for me to have a nice oneline output of git log, yust try this:
git log --pretty=format:"%C(auto)%ad %h %<(15,trunc)%C(dim white)%an %C(auto)%d %s"
it should print the same number of lines like git rev-list
but in a better human readable format, including date, Authors, short-commit-hast and commit-message
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With