Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log with diff for a certain file

How can one get log listing combined with the differences in each commit
ie:

commit1  
Author
Date  
Commit message
changes between commit1 and commit2

commit2  
Author
Date
Commit message
changes between commit2 and commit3
...

Using
git log /some/file
Gives a listing of the commits that changed some/file

ie:

commit1  
Author
Date  
Commit message

commit2  
Author
Date
Commit message
...

However, the changes in each commit doesn't get displayed

Using
git diff hash1..hash2 /some/file
Gives the changes in /some/file between those two commits.
But only between those 2 commits, not through all the commits that changed /some/file

like image 560
weshouman Avatar asked Jul 28 '16 12:07

weshouman


People also ask

Can you git diff a specific file?

The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.

How do I see diff in git log?

Regular git log -p -- A will show all commits that touch file A, and for those commits, it'll show the diffs to A. With --full-diff , it'll show the same commits, but for each commit it'll show the diff of all files changed in that commit. In this case, commit C's diff will show diffs for files A and B.

How can I find the difference between two commits in a file?

To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..


1 Answers

According to https://git-scm.com/docs/git-log you can use

git log -p path 
to show commits that touch the specified paths, and diffs about the same specified paths.
like image 51
SzymonPajzert Avatar answered Oct 13 '22 03:10

SzymonPajzert