1

I've got a merge commit, and I can show the entirety of it using git show -m. However, if I want to only show the change for a subfolder or a path, how do I do it? I tried doing git show -m -- app/ but it didn't show anything, even though git show --stat indicates that there were merges going on in that part of the repository.

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
  • `git show -m app/` *should* work, as `-m` should override the usual combined-diff issues. You may still get two (or more) diffs from this since `git show -m` actually runs two (or more) diff commands internally, one for each parent. You can also do `git diff commit^ commit -- app/` and `git diff commit^2 commit -- app/` to diff parent#1 vs commit, or parent#2 vs commit. – torek Jun 20 '16 at 05:19
  • @torek I actually typed `git show -m -- app/` (sorry), though doing `git show -m app/` gave the same results. – Andrew Grimm Jun 20 '16 at 05:22
  • Oh, actually, I'm wrong: `git show -m -- app/` fails because (apparently) `git show` does not handle `git diff` style path limiting at all. You'll have to resort to the `git diff` commands, or use `--relative` as krzyk answered. – torek Jun 20 '16 at 05:23

1 Answers1

2

You can use --relative for that:

git show -m --relative=app/

But it will show paths relative to the directory provided in the path:

--relative[=<path>]

When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument.

Community
  • 1
  • 1
Krzysztof Krasoń
  • 26,515
  • 16
  • 89
  • 115