12

My last commit updated ~300 files, and the diff page says Sorry, we could not display the entire diff because it was too big and is so slow that I can barely scroll it. How can I see changes for a single file?

When viewing a specific file, I expected to have a link to compare it with the previous version, but I can't find any. Am I missing something or why isn't such an important feature there?

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
riv
  • 6,846
  • 2
  • 34
  • 63
  • @riv - could you link to the source file? I don't have an example of that size on hand. – mbb Jul 16 '15 at 15:15
  • @mjb: https://github.com/d07RiV/d3planner/blob/master/scripts/bnet-parser.js – riv Jul 16 '15 at 15:57

3 Answers3

1

Use git diff. It can take revision and file arguments.

git diff master ./myawesomefile.txt 

will show how master's version of the file differs from your local version

git diff 878a984e ./myawesomefile.txt

will show how commit hash 786876 differs from your current local version

git diff 878a984e 48d74774 ./myawesomefile.txt

will show how commit hash 878a984e version of myawesomefile.txt differs from 48d74774

iphipps
  • 529
  • 1
  • 7
  • 20
  • 1
    In case git gets confused about which parameters are git refs and which are files, you get into the habit of adding `--` between the refs and the files. `git diff 878a98ae -- acefile 432.txt` – Paul Hicks Sep 18 '18 at 21:31
0

I think you're looking for this cheatsheet. You can compare across time like this link does with master@%7B2015-02-27%7D...master in the end or across commits for specific files like this one does with ^ after the base you want to compare.

I tend to do this all locally using git fetch master && git diff ..master to compare my current branch to an updated master, but you certainly can do this with the above.

mbb
  • 3,052
  • 1
  • 27
  • 28
0

You can view the change history of a file by clicking on the history button, or by adding commits to the url of the file. Here is what it looks like for a file at the homebrew repo on github.

e.g.

https://github.com/mxcl/homebrew/commits/master/SUPPORTERS.md

Or you can try:

On GitHub, there are, essentially, two different ways to see the commit history of a repository:

By navigating directly to the commits page of a repository.

By clicking on a file, then selecting History, to get to the commit history for a specific file.

For more information on how Git considers commit history, you can read up on the "History Simplification" section of the [git log][2] help article.

Moises Gonzaga
  • 151
  • 1
  • 17
  • The last link points to an anchor in the full diff, which isn't very helpful in my case since my diff doesn't even list all the files. – riv Jul 16 '15 at 15:59
  • @riv In that case, use "Blame" option, that is explicit in the first method: https://github.com/d07RiV/d3planner/blame/master/scripts/bnet-parser.js – Moises Gonzaga Jul 16 '15 at 16:12
  • or replace in your url with the specific id commit: https://github.com/d07RiV/d3planner/commit/dbcce5c5648ea7aa1d1c6c065dc3348e50501101 [link](https://help.github.com/articles/getting-permanent-links-to-files/) – Moises Gonzaga Jul 16 '15 at 16:16
  • Yeah I tried Blame but its not as good as a proper diff since it doesn't show the original contents. – riv Jul 16 '15 at 17:38
  • @riv .... well riv, I have two more option, I hope and it can help you. 1.- Install GitHub por PC [link](https://windows.github.com/), login with you credentials and to this [link](http://www.amaslo.com/2012/09/how-to-avoid-github-clients-diff-is-too.html) or 2.- Install Git for Windows [link](https://msysgit.github.io/), and use the line command `gitk [filename]` as appear here [link](http://stackoverflow.com/questions/278192/view-the-change-history-of-a-file-using-git-versioning). If I find other solution I'll share with you as soon as possible. – Moises Gonzaga Jul 16 '15 at 19:29
  • I couldn't find another way. Sorry Riv. – Moises Gonzaga Jul 21 '15 at 16:59
  • Thanks for the github history tipp! Awesome:) – leonnicklas Sep 29 '22 at 06:57