Questions tagged [git-diff]

Shows changes between the working tree and the committed contents of a git repository, or between two commits or branches of the repository.

git-diff(1) shows changes between the working tree and the committed contents of a git repository, or between two commits or branches of the repository.

It has a number of options to control which versions to diff and also how the produced diff output is formatted, see the man-page for details.

1085 questions
218
votes
5 answers

Git: How to diff two different files in different branches?

I have two different files in different branches. How can I diff them in one command? Something like # git diff branch1/foo.txt branch2/foo-another.txt I could check out the other file, diff it and restore, but that's quite dirty solution.
Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
192
votes
5 answers

Is there a way of having git show lines added, lines changed and lines removed?

git diff --stat and git log --stat show output like: $ git diff -C --stat HEAD c9af3e6136e8aec1f79368c2a6164e56bf7a7e07 app/controllers/application_controller.rb | 34 +++------------------------- 1 files changed, 4 insertions(+), 30…
Juan Alonso
  • 2,125
  • 2
  • 15
  • 16
189
votes
15 answers

How can I see 'git diff' on the Visual Studio Code side-by-side file?

I would like to know how to see as a file with the command git diff master origin/master in the terminal on Visual Studio Code. I did a git fetch from my remote repository, and now I want to see the diff, but with the command just show me in the…
189
votes
15 answers

How to get diff working like git-diff?

I like the output formatting of git diff. The color and the +/- representation of changes between lines is easier to read than GNU diff. I can run git diff using --no-index flag outside of a git repo and it works fine. However, it appears to be…
Mzzzzzz
  • 4,770
  • 7
  • 30
  • 47
179
votes
25 answers

There isn't anything to compare. Nothing to compare, branches are entirely different commit histories

I have a CMS theme installed on my machine. I'm tracking changes to it via git and decided to back it up on GitHub so I could share those changes. The theme as provided is also available on GitHub. On my machine I have added this as a remote…
Jack
  • 2,245
  • 2
  • 14
  • 18
175
votes
5 answers

How to Diff between local uncommitted changes and origin

Let's say I cloned a repository and started modifying files. I know that if I have local uncommitted changes, I can do a diff as follows git diff test.txt and it will show me the difference between the current local HEAD and the modified,…
Chaitanya
  • 5,203
  • 8
  • 36
  • 61
164
votes
2 answers

How to download a single commit-diff from GitHub?

I would like to get a single commit (let's call it ${SHA}) from GitHub via the web-interface. For example, something like: $ git clone http://github.com/foo/bar $ cd bar $ git format-patch -o .. ${SHA}~1..${SHA} $ cd .. $ rm -rf bar ...but without…
umläute
  • 28,885
  • 9
  • 68
  • 122
159
votes
2 answers

Differences for a certain folder between git branches

As in the title, I want to have a diff file for a certain folder between the master branch and a branch I have created.
Wazery
  • 15,394
  • 19
  • 63
  • 95
156
votes
10 answers

How can I view file history in Git?

With Subversion I could use TortoiseSVN to view the history/log of a file. How can I do this with Git? I am just looking for the history record for a particular file, and then the ability to compare the different versions.
mrblah
  • 99,669
  • 140
  • 310
  • 420
155
votes
7 answers

How do I get git diff with full context?

How do I create a patch with full context? I tried --unified=2000, which gives 2000 lines of context: git diff --unified=2000 branch master --no-prefix > patch How do I include all the lines in the file without having to specify the maximum number…
balki
  • 26,394
  • 30
  • 105
  • 151
148
votes
8 answers

Making git diff --stat show full file path

On doing git diff --stat some files are listed with full path from repository base but some files are listed as: .../short/path/to/filename. That is the path starts with ... and only short path is shown. I would like git diff to list full file…
Badri
  • 1,973
  • 2
  • 14
  • 16
145
votes
5 answers

How to "git show" the diffs for a merge commit?

When I have a merge commit and run git show , it shows only the commit log, not the the diffs: commit c0f50178901e09a1237f7b9d9173ec5d1c4936c Merge: ed234b ded051 Author: abc Date: Mon Nov 21 15:56:33 2016 -0800 Merge branch…
Sohaib Farooqui
  • 1,459
  • 2
  • 10
  • 5
132
votes
11 answers

How can I get the diff between all the commits that occurred between two dates with Git?

Or just all the commits that occurred between two dates? In SVN, you could do something like svn diff -r{date}:{date} to do it! I can't seem to find a Git equivalent to this. Specifically I'm looking at writing a script to send out daily emails…
Chris
  • 3,184
  • 4
  • 26
  • 24
110
votes
6 answers

"git diff" does nothing

I presume this is a configuration error somewhere, but I can't figure out where. Regular git commands appear to work fine, but "git diff" does nothing. To be safe, I removed external diff tools from my .gitconfig file. This was installed via…
Tom Lianza
  • 4,012
  • 4
  • 41
  • 50
109
votes
5 answers

git diff - show me line ending changes?

My editor is changing the line endings of my source files. When I do git diff, I see the same line twice -- once with - and once with + -- with no visible difference. How do I get git diff to show me what this change actually was?
Stonky
  • 1,141
  • 2
  • 7
  • 6
1 2
3
72 73