How to get git log -p to show changes in merge commits


5 seconds

I have a branch with a missing function definition, but the function is still being used, causing a crash. Feature definitions must have been removed during the merge. I've done 'git log -p' and searched for the function definition, and I can see it's being defined, but I can't find it removed later. This leads me to believe that git log -p doesn't show merged changes? How to get this feature?

Tuesday

This leads me to believe that git log -p doesn't show merged changes? How to get this feature?

You are correct: by default, git log -pyou are shown merge commits, but they don't even try to show diffs.

As odradek wrote in the comments , adding that -coption will make the combined diffgit log show . You can also use (note, two dashes , as opposed to one dash ), which also shows the combined diff, or , which effectively splits the merge for diff purposes , and shows each parent against that parent a difference.--cc--cc-c-m

These three options can be used with git show. However, for whatever reason, the git show default is --ccwhile , and the default git logis empty .

The difference between these three options is only clear when doing certain merges, it's a little tricky to show them. However, we can make one thing clear: diffs of any combination only show files that differ from all parents. That said, whatever is shown is trimmed to git show -chelpgit show --cc you. (Depending on what --cccan be displayed, the table may be more than trimmed -c. I don't have an example handy, though.)

For example, consider committing 3e5c63943d35be1804d302c0393affc4916c3dc3to Git in a Git repository . This is a merge (with parent c13c783...and 20690b2..., if we run two separate git diff commands, we can see that only two files have changed compared to its first parent :

$ git diff --name-status 3e5c639^1 3e5c639
M       builtin/remote.c
M       t/t5505-remote.sh

But many files (including the same two files) changed compared to the second parent file :

$ git diff --name-status 3e5c639^2 3e5c639 | expand
M       .gitignore
M       .mailmap
M       Documentation/Makefile
A       Documentation/RelNotes/2.12.0.txt
M       Documentation/SubmittingPatches
A       Documentation/asciidoctor-extensions.rb
M       Documentation/blame-options.txt
M       Documentation/cat-texi.perl
M       Documentation/config.txt
M       Documentation/diff-config.txt
[snipped here - but the same two files do appear in the 339-entry list]

If I git show --ccrely on that, then I don't get any diff list at all. If I run git show -cit, I get a diff listed builtin/remote.cand t/t5505-remote.sh.

If I git show -mprocess this, I get two separate git diffmanifests. Nor is it a "combination difference". The first starts with:

commit 3e5c63943d35be1804d302c0393affc4916c3dc3 (from
 c13c783c9d3d7d3eff937b7bf3642d2a7fe32644)

and only show the first two files. The second starts with:

commit 3e5c63943d35be1804d302c0393affc4916c3dc3 (from
 20690b213975ad3e9b1bc851f434d818bd2d1de9)

and shows all 339 files.

Use -mis "a real big hammer", but you'll need a lot of sorting work to accomplish many tasks. Using --ccor -cis usually sufficient.

(Something else you might need to do when making such changes using .js git log -pis adding --full-historyto ensure that bothgit log branches are followed after every merge . This is only needed if you're simplifying the history by adding options .)-- <path>

Related


How to get git log -p to show changes in merge commits

5 seconds I have a branch with a missing function definition, but the function is still being used, causing a crash. Feature definitions must have been removed during the merge. I've done 'git log -p' and searched for the function definition, and I can see it'

How to get git log -p to show changes in merge commits

5 seconds I have a branch with a missing function definition, but the function is still being used, causing a crash. Feature definitions must have been removed during the merge. I've done 'git log -p' and searched for the function definition, and I can see it'

How to get git log -p to show changes in merge commits

5 seconds I have a branch with a missing function definition, but the function is still being used, causing a crash. Feature definitions must have been removed during the merge. I've done 'git log -p' and searched for the function definition, and I can see it'

How to get git log -p to show changes in merge commits

5 seconds I have a branch with a missing function definition, but the function is still being used, causing a crash. Feature definitions must have been removed during the merge. I've done 'git log -p' and searched for the function definition, and I can see it'

How to get git log for only current branch and merge commits

KT8 I'm using this git command to get the logs (from a specific commit) in reverse order, with the commit details: git log eab3e0ffdsfs.. --reverse -M --numstat --summary --pretty=format:commitId:%H%ndate:%cd%nsubject:%s%nauthor:%an%n This gave me all commits

How to get git log for only current branch and merge commits

KT8 I'm using this git command to get the logs (from a specific commit) in reverse order, with the commit details: git log eab3e0ffdsfs.. --reverse -M --numstat --summary --pretty=format:commitId:%H%ndate:%cd%nsubject:%s%nauthor:%an%n This gave me all commits

How to make "git merge --log" stop flattening merge commits

c_spk I'm using the successful git branching model , where your masterbranch consists only of version-tagged merge commits and all development happens on the developbranch. This developbranch also includes merge commits (feature branches) and normal commits (s

How to make "git merge --log" stop flattening merge commits

c_spk I'm using the successful git branching model , where your masterbranch consists only of version-tagged merge commits and all development happens on the developbranch. This developbranch also includes merge commits (feature branches) and normal commits (s

How to get parents of merge commits in git?

Casebash Some git commands have the parent as the revision; others (for example git revert) as the parent number. How to get parents in both cases. I don't want to use the graphical log command as that usually requires scrolling down a long tree to find the se

How to get all commits of a merge request in git?

Lee Jenkins This git show --rawcommand will show if commit hashes are generated from merges: $ git show --raw -m 3d1718 commit 3d1718fb99d52d35700b596bac45caffd1af00dc (from 8923654049aa49c4813fa612e4108271e0361240) Merge: 8923654 3f1a071 ... In the case of a

How to get parents of merge commits in git?

Casebash Some git commands have the parent as the revision; others (for example git revert) as the parent number. How to get parents in both cases. I don't want to use the graphical log command as that usually requires scrolling down a long tree to find the se

How to get all commits of a merge request in git?

Lee Jenkins This git show --rawcommand will show if commit hashes are generated from merges: $ git show --raw -m 3d1718 commit 3d1718fb99d52d35700b596bac45caffd1af00dc (from 8923654049aa49c4813fa612e4108271e0361240) Merge: 8923654 3f1a071 ... In the case of a

How to get parents of merge commits in git?

Casebash Some git commands have the parent as the revision; others (for example git revert) as the parent number. How to get parents in both cases. I don't want to use the graphical log command as that usually requires scrolling down a long tree to find the se

View git log no merge commits

Mu None: I'm trying to view commits for a specific user and would like to remove from the output any merges done by that user. what should I do? I can use to check the user's commits git log --author=<name>, but not delete the merge commits in the output. PS:

View git log no merge commits

Mu None: I'm trying to view commits for a specific user and would like to remove from the output any merges done by that user. what should I do? I can use to check the user's commits git log --author=<name>, but not delete the merge commits in the output. PS:

View git log no merge commits

Mu None: I'm trying to view commits for a specific user and would like to remove from the output any merges done by that user. what do I do? I can use to check the user's commits git log --author=<name>, but not delete the merge commits in the output. PS: Merg

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

How to make `git log --name-status` work with merge commits?

invalid pointer I would like to see a list of files in the log along with the diff status corresponding to each commit. To do this for a normal commit, it's as simple as: $ git log --oneline --graph --name-status However, for merge commits, the file list is b

git log -p path/to/file doesn't show all changes

x-yuri I want it to show all changes (commits) to the specified file, but it doesn't do that. It only shows some of them. I guess it has something to do with merging, but I don't see what could be wrong here. Can someone explain? UPD I was able to reproduce my