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.

938 questions
2502
votes
1 answer

Comparing two branches in Git?

I have two branches, branch_1 and branch_2. How can I see the differences between the two branches in Git?
isuruanu
  • 25,085
  • 3
  • 12
  • 4
2275
votes
14 answers

How do I show the changes which have been staged?

I staged a few changes to be committed; how can I see the diff of all files which are staged for the next commit? I'm aware of git status, but I'd like to see the actual diffs - not just the names of files which are staged. I saw that the…
Frerich Raabe
  • 81,733
  • 18
  • 105
  • 196
2208
votes
14 answers

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

I have a bunch of commits in the repo. I want to see a list of files changed between two commits - from SHA1 to SHA2. What command should I use?
Shawn
  • 28,051
  • 17
  • 43
  • 68
2207
votes
18 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 which was quite useful. The tools to compare branches I've come across…
johannix
  • 27,528
  • 14
  • 37
  • 41
1942
votes
26 answers

Viewing unpushed Git commits

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
  • 23,638
  • 9
  • 27
  • 45
1801
votes
21 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
  • 47,916
  • 15
  • 112
  • 150
1748
votes
13 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. Are there any ways to do this? To be clear I'm not looking for a compare tool (I use Beyond Compare).…
Micah
  • 101,237
  • 81
  • 221
  • 320
1243
votes
11 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
  • 65,753
  • 43
  • 162
  • 239
1028
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
  • 18,841
  • 37
  • 93
  • 134
1011
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
  • 11,893
  • 5
  • 25
  • 33
567
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
  • 7,739
  • 4
  • 18
  • 27
539
votes
10 answers

git-diff to ignore ^M

In a project where some of the files contains ^M as newline separators. Diffing these files are apparently impossible, since git-diff sees it as the entire file is just a single line. How does one diff with the previous version? Is there an option…
neoneye
  • 44,507
  • 23
  • 155
  • 143
495
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
  • 5,687
  • 3
  • 18
  • 21
480
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,411
  • 5
  • 17
  • 17
466
votes
4 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
  • 186,044
  • 29
  • 86
  • 92
1
2 3
62 63