6

What is the difference between the 2 commands below. I see different outputs.
Both are run from a clone having a single branch.

git whatchanged -m -- foo.c

git rev-list --reverse --all -- foo.c
Senthil A Kumar
  • 10,306
  • 15
  • 44
  • 55

1 Answers1

3

As mentioned in the git whatchanged man page:

Shows commit logs and diff output each commit introduces.
The command internally invokes git rev-list piped to git diff-tree, and takes command line options for both of these commands.

The "piped to git diff-tree" would explain the different output between both commands.

You can find an example of git rev-list combined with a git diff in "In git, how can I get the diff between all the commits that occured between two dates?".


Update September 2013:

The new version of the man page for git whatchanged now emphasizes:

New users are encouraged to use git log instead. The whatchanged command is essentially the same as git log but defaults to show the raw format diff output and to skip merges.

The command is kept primarily for historical reasons; fingers of many people who learned Git long before git log was invented by reading Linux kernel mailing list are trained to type it.

See more at "Difference between git-log and git-whatchanged?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks!, so if i want to see what happened to a file (check for code-loss in merges or something), which command should be the best? – Senthil A Kumar Dec 07 '11 at 07:53
  • @SenthilAKumar: if it involves checking the changes of *content*, then `git whatchanged` is a good start. The question I link to in my answer provides other alternatives based on `git diff`. – VonC Dec 07 '11 at 07:55
  • @SenthilAKumar: I don't see your edit. Your initial question appears to be untouched. – VonC Dec 07 '11 at 11:47
  • Similar question follows on http://stackoverflow.com/questions/8414940/git-log-and-git-whatchanged-shows-2-commits-but-both-have-same-lines-added-so – Senthil A Kumar Dec 07 '11 at 11:59