Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git-Diff vs. Git-log? What's the difference?

Tags:

git

I'm a little bit confused about Git. When I'm looking through the manual it appears the Diff is included in the Git-log manual. Also when I'm looking at tutorials and stuff, I find that Git log does much of the same stuff git-diff does. Is Git-Diff's functionality just a subset of Git-log?

Thanks!

like image 577
Matt Avatar asked Dec 30 '09 02:12

Matt


People also ask

What is the difference between git log and git show?

Git Show command is similar to git log in terms of output. Git show also presents you the output in the same format as we studied in the git log tutorial. A slight difference is that the git show command shows you two things: The commit to which HEAD is pointing.

What does git diff mean?

Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.

What is git log for?

What does git log do? The git log command displays all of the commits in a repository's history. By default, the command displays each commit's: Secure Hash Algorithm (SHA)

What is the difference between the git diff and git status?

The main difference between the commands is that git diff is specially aimed at comparisons, and it's very powerful at that: It can compare commits, branches, a single file across revisions or branches, etc. On the other hand, git status is specifically for the status of the working tree.


1 Answers

git log can use git diff to display each change in the history. git log is for displaying a set of revisions, potentially including the diff between each revision and its parent, while git diff is used for displaying the difference between any two revisions in your repository.

git diff can also be used to display diffs between the current working copy and the staging area (also known as the "index"), and diffs between the staging area and a revision in your repository, usually HEAD, while git log will only ever show committed code.

So, they do have a bit of overlap, but neither one is a subset of the other. git log uses git diff for some forms of its display, and thus has the same options for setting how it calls git diff.

like image 197
Brian Campbell Avatar answered Oct 03 '22 22:10

Brian Campbell