Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different result from git log and git rev-list

Tags:

git

bash

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?

like image 807
loannnlo Avatar asked Mar 01 '18 09:03

loannnlo


2 Answers

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.

like image 53
torek Avatar answered Sep 27 '22 22:09

torek


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

like image 43
Radon8472 Avatar answered Sep 27 '22 22:09

Radon8472