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
3020
votes
9 answers

How do I see the differences between two branches?

How do I see the differences between branches branch_1 and branch_2?
isuruanu
  • 30,273
  • 3
  • 14
  • 4
2615
votes
15 answers

How to list only the names of files that changed between two commits

I have a bunch of commits in the repository. I want to see a list of files changed between two commits - from SHA1 to SHA2. What command should I use?
Shawn
  • 32,509
  • 17
  • 45
  • 74
2560
votes
16 answers

How do I show the changes which have been staged?

I staged a few changes to be committed. How do I see the diffs of all files which are staged for the next commit? Is there a handy one-liner for this? git status only shows names of files which are staged, but I want to see the actual diffs. The…
Frerich Raabe
  • 90,689
  • 19
  • 115
  • 207
2334
votes
21 answers

Showing which files have changed between two revisions

I want to merge two branches that have been separated for a while and wanted to know which files have been modified. Came across this link: http://linux.yyz.us/git-howto.html (moved to web.archive.org) which was quite useful. The tools to compare…
johannix
  • 29,188
  • 15
  • 39
  • 42
2258
votes
27 answers

How to list unpushed Git commits (local but not on origin)

How can I view any local commits I've made, that haven't yet been pushed to the remote repository? Occasionally, git status will print out that my branch is X commits ahead of origin/master, but not always. Is this a bug with my install of Git, or…
Josh Buhler
  • 26,878
  • 9
  • 29
  • 45
2233
votes
26 answers

How can I see the changes in a Git commit?

When I do git diff COMMIT I see the changes between that commit and HEAD (as far as I know), but I would like to see the changes that were made by that single commit. I haven't found any obvious options on diff / log that will give me that output.
laktak
  • 57,064
  • 17
  • 134
  • 164
2133
votes
14 answers

How to compare files from two different branches

I have a script that works fine in one branch and is broken in another. I want to look at the two versions side-by-side and see what's different. Is there a way to do this? To be clear I'm not looking for a compare tool (I use Beyond Compare). I'm…
Micah
  • 111,873
  • 86
  • 233
  • 325
1418
votes
12 answers

How do I diff the same file between two different commits on the same branch?

In Git, how could I compare the same file between two different commits (not contiguous) on the same branch (master for example)? I'm searching for a compare feature like the one in Visual SourceSafe (VSS) or Team Foundation Server (TFS). Is it…
systempuntoout
  • 71,966
  • 47
  • 171
  • 241
1278
votes
7 answers

How to exit git log or git diff

I'm trying to learn Git with the help of Git Immersion. There's one thing that frustrates me whenever I use git log or git diff: I can't figure out what to do next when I encounter this (END) word. I can't type any commands, and I end up closing…
Wern Ancheta
  • 22,397
  • 38
  • 100
  • 139
1144
votes
3 answers

Show git diff on file in staging area

Is there a way I can see the changes that were made to a file after I have done git add file? That is, when I do: git add file git diff file no diff is shown. I guess there's a way to see the differences since the last commit but I don't know what…
arod
  • 13,481
  • 6
  • 31
  • 39
678
votes
13 answers

Make 'git diff' ignore ^M

In a project where some of the files contain ^M as newline separators, diffing these files is apparently impossible, since git diff sees the entire file as just a single line. How does one git diff when comparing the current and previous versions of…
neoneye
  • 50,398
  • 25
  • 166
  • 151
659
votes
2 answers

How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?

I have a .diff file created by a coworker, and would like to apply the changes listed in that diff file to my local branch of the exact same repository. I do not have access to that worker's pc or branch that was used to generate this diff…
Mike_K
  • 9,010
  • 5
  • 20
  • 27
587
votes
5 answers

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

Some Git commands take commit ranges and one valid syntax is to separate two commit names with two dots .., and another syntax uses three dots .... What are the differences between the two?
Pat Notz
  • 208,672
  • 30
  • 90
  • 92
576
votes
10 answers

How to view file diff in git before commit

This often happens to me: I'm working on a couple related changes at the same time over the course of a day or two, and when it's time to commit, I end up forgetting what changed in a specific file. (This is just a personal git repo, so I'm ok with…
Sauce McBoss
  • 6,567
  • 3
  • 20
  • 22
512
votes
8 answers

How to diff a commit with its parent

Aside from writing an alias or script, is there a shorter command for getting the diff for a particular commit? git diff 15dc8^..15dc8 If you only give the single commit id git diff 15dc8, it diffs that commit against HEAD.
Brian L
  • 10,757
  • 5
  • 19
  • 17
1
2 3
72 73