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
450
votes
15 answers

Show diff between commits

I am using Git on Ubuntu 10.04 (Lucid Lynx). I have made some commits to my master. However, I want to get the difference between these commits. All of them are on my master branch. For example: commit dj374 made changes commit y4746 made…
ant2009
  • 27,094
  • 154
  • 411
  • 609
412
votes
15 answers

Exclude file from "git diff"

I am trying to exclude a file (db/irrelevant.php) from a Git diff. I have tried putting a file in the db subdirectory called .gitattributes with the line irrelevant.php -diff and I have also tried creating a file called .git/info/attributes…
Michael
  • 4,597
  • 2
  • 17
  • 16
409
votes
14 answers

How to diff one file to an arbitrary version in Git?

How can I diff a file, say pom.xml, from the master branch to an arbitrary older version in Git?
Chris K
  • 11,996
  • 7
  • 37
  • 65
355
votes
6 answers

How to show uncommitted changes in Git and some Git diffs in detail

How do I show uncommitted changes in Git? I STFW'ed, and these commands are not working: teyan@TEYAN-THINK MINGW64 /d/nano/repos/PSTools/psservice (teyan/psservice) $ git status On branch teyan/psservice Your branch is up-to-date with…
TD_Yan
  • 3,591
  • 2
  • 12
  • 5
337
votes
6 answers

How to read the output from git diff?

The man page for git-diff is rather long, and explains many cases which don't seem to be necessary for a beginner. For example: git diff origin/master
poseid
  • 6,986
  • 10
  • 48
  • 78
332
votes
12 answers

Can I make 'git diff' only display the line numbers AND changed file names?

This question calls for "line numbers". If you do not care about line numbers in the output, see this question and answer. Basically, I don't want to see the changed content, just the file names and line numbers.
wei
  • 6,629
  • 7
  • 40
  • 52
292
votes
5 answers

Git diff between current branch and master but not including unmerged master commits

I want a diff of all changes in a branch that is not merged to master yet. I tried: git diff master git diff branch..master git diff branch...master However, in each of these cases the diff contains content in master that has not been merged into…
pillarOfLight
  • 8,592
  • 15
  • 60
  • 90
292
votes
12 answers

Getting the difference between two repositories

How can we get the difference between two git repositories? The scenario: We have a repo_a and repo_b. The latter was created as a copy of repo_a. There have been parallel development in both the repositories afterwards. Is there a way we can list…
sanjayav
  • 4,896
  • 9
  • 32
  • 30
276
votes
3 answers

git diff file against its last change

Is it possible to get git to produce a diff between a specific file as it exists now, and as it existed before the last commit that changed it? That is, if we know: $ git log --oneline myfile 123abc Fix some stuff 456def Frobble the foos 789dba…
Chowlett
  • 45,935
  • 20
  • 116
  • 150
275
votes
6 answers

Create patch or diff file from git repository and apply it to another different git repository

I work on WordPress based project and I want to patch my project at each new release version of WP. For this, I want generate a patch between two commits or tags. For example, in my repo /www/WP I do this: $ git patch-format com1..com2 --stdout >…
zatamine
  • 3,458
  • 3
  • 25
  • 33
269
votes
5 answers

What are the differences between double-dot ".." and triple-dot "..." in Git diff commit ranges?

What are the differences between the following commands?: git diff foo master # a git diff foo..master # b git diff foo...master # c The diff manual talks about it: Comparing branches $ git diff topic master <1> $ git diff topic..master …
chrisjlee
  • 21,691
  • 27
  • 82
  • 112
256
votes
8 answers

Difference between file in local repository and origin

I want to find the differences between a file I have in my local repository vs. what is in the origin master. I know that there is git diff. However, I just want to isolate it down to this one particular file. For simplicity, let’s say the file is…
SeekingAlpha
  • 7,489
  • 12
  • 35
  • 44
252
votes
19 answers

How can I get a side-by-side diff when I do "git diff"?

When I type git diff, I'd like to see a side-by-side diff, like with diff -y, or like to display the diff in an interactive diff tool like kdiff3. How can this be done?
user783774
237
votes
2 answers

Git list of staged files

I staged a lot of files using git add, and now I want to see all the files I have staged, without untracked files or changed, but unstaged files. How do I do that? When using git diff --cached I can see the changes of what I just staged. So then I…
Timon de Groot
  • 7,255
  • 4
  • 23
  • 38
232
votes
4 answers

How to make git-diff and git log ignore new and deleted files?

Sometimes there's a couple of changed files together with some new, deleted and/or renamed files. When doing git diff or git-log I'd like to omit them, so I can better spot the modifications. Actually, listing the names of the new and deleted files…
maaartinus
  • 44,714
  • 32
  • 161
  • 320
1
2
3
72 73