Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single-file diff between two commits

Tags:

github

In github, is it possible to show the diff of a single file between two commits?

One can readily diff two commits, and it is possible to link to the anchor for a specific file in those two commits, but all files are included in that view. For example, https://github.com/adamginsburg/APEX_CMZ_H2CO/compare/a94a962db51e0f4e73ec3ba4170a0ca8269548da...adamginsburg:master#diff-22

I would like a similar view, but without the other files.

(I know how to do this on the command line with git, but I want to share this link with collaborators, so the command line approach is not relevant for this question)

like image 661
keflavich Avatar asked Mar 12 '15 10:03

keflavich


People also ask

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..

How do I get the diff of a file in git?

By executing the git diff command, we can see the differences between these two files. By default, the git diff command produces a diff for all files between the latest commit and the current state of the repository.

Can we compare two commits in git?

You can also compare two arbitrary commits in your repository or its forks on GitHub in a two-dot diff comparison. To quickly compare two commits or Git Object IDs (OIDs) directly with each other in a two-dot diff comparison on GitHub, edit the URL of your repository's "Comparing changes" page.

Which command is used to compare two commits?

One of them is doing comparisons. In Git, you use the command git diff to compare commits, branches, individual files and more.


1 Answers

I think your question can be consider a duplicate of this one :

How can I generate a diff for a single file between two branches in github

Unfortunately, the accepted answer doens't answer your expected behavior.

I really tried to exclude the other files without success, and since there not seems to have other means to filter it out but html anchor pointer, I guess what you already have is what best available with Github to pin point the change you want to talk about with your peers.

like image 177
Richard Avatar answered Oct 13 '22 21:10

Richard