2

I have the following global setting in my .gitconfig file:

commit.verbose=true

I really like seeing the file edits in vim when I'm writing a commit message. Is is also possible to have this functionality when using git merge?

The verbose flag in when merging doesn't have the same behavior as the commit verbose flag.

EDIT: Here are some screen shots to explain what I'm talking about:

Committing some edits to my develop branch and writing the message in vim could look something like. The commit.verbose flag is set to true as I noted above:

$ git commit -a

enter image description here

Now attempting to merge the changes into another branch (i.e. master) results in the following:

$ git checkout master && git merge -v --no-ff develop

enter image description here

I think the verbose option you see on the the git docs, and I used in the command above, and related to the output after a successful merge. In my example case the output was:

Merge made by the 'recursive' strategy.
 README | 2 ++
 1 file changed, 2 insertions(+) 

Bumping up the verbosity to level 5 doesn't do what I'm asking:

$ GIT_MERGE_VERBOSITY=5 git merge -v --no-ff develop
Merging:
1b4c630 Initial commit
virtual develop
found 1 common ancestor:
1b4c630 Initial commit
Merge made by the 'recursive' strategy.
 README | 2 ++
 1 file changed, 2 insertions(+)

EDIT: The closest answer to my question is found in one of the answers listed HERE, essentially I get the entire diff if I execute the following before the merge

git diff <commit1> <commit2>

EDIT 2: Another way to see the full merge commit the same as a commit message is by first merging the branch, and then running

git commit --amend

This makes it possible to see the merge commit as a normal commit, at least with respect to seeing the full diff.

cbcoutinho
  • 634
  • 1
  • 12
  • 28
  • 1
    Not really a solution but what I'm doing is `git merge --no-commit`, so its merging without final commit, then I'm doing `git commit` to see changes and maybe amend message. – pbogut Aug 08 '18 at 08:15

2 Answers2

2

I think you might be looking for merge.verbosity:

merge.verbosity

Controls the amount of output shown by the recursive merge strategy. Level 0 outputs nothing except a final error message if conflicts were detected. Level 1 outputs only conflicts, 2 outputs conflicts and file changes. Level 5 and above outputs debugging information. The default is level 2. Can be overridden by the GIT_MERGE_VERBOSITY environment variable.

https://git-scm.com/docs/git-merge#git-merge-mergeverbosity

Edit: based on your update with screenshots, I think I have to change my answer to: no, near as I can tell there is no way to do what you're asking with vanilla Git. Even fugitive (which I highly recommend BTW) doesn't really provide anything like that. I note this possibly relevant question.

Rich Churcher
  • 7,361
  • 3
  • 37
  • 60
1

there is a round-about way, steps are:

  1. git merge # ... your options
  2. delete the commit message or comment and save an empty merge commit message
    • git aborts the merge commit
  3. git commit
    • git creates the merge commit message with all diffs as usual
IljaBek
  • 601
  • 11
  • 21