Search code examples
gitphpstorm

How to see changes made by me in merge commit


In git, how can I see changes made ONLY by me in last merge commit? to see only lines changed be me, not lines changed by somebody else.

Typically when I push and there is conflict, I do merge and solve some conflicts. After resolving them, I want to review conflict that I've solved. I use:

git show HEAD

to see last merge commit, it shows some useful information, but it also show changes made by someone else, that do not conflict with my changes. Or my changes, that do not conflict with other person's changes.

example output of git show HEAD:

  1.
- 2.
+ 2. zzzz
  3.
  4.
 -5. change A
 +5. change B
  6.
  7.
 -8.
 +8. zzzzzz
  9.
- 10.
+ 10.

I see not conflicting changes in lines 2 and 8, that do not interest me that much. And conflicting line 5 that I am really interested in.

Ideally I would like to see. What other person has in this line, what I have in this line, and how it was resolved (with name of each person, for example author A: version A, Author B: version B, resolved to X by author A).

And if it is possible, if I could see this in Phpstorm IDE (based on Jetbrains IDEA) or other GUI that highlights changed characters?

example git repo: https://github.com/LPodolski/git-merge-show-my-changes (I posted commits with same email, but author's aliases are different, you can see that in your console using git log).

Have a nice day.


Solution

  • Does this help?

    git log -p --author=<authorname/yourname>

    EDIT: Ok I have long answer:

    Since you know the commit with resulted after merging of the things:

    Step 1: Get the commit hash

    git log --author=Uday --merges -p -2

    This lists all the commits involved in the merge. Example output:

    commit 1c46adfadsf
    Merge: 0bfda16 d8340ff
    Author: Uday <[email protected]>
    Date:   Tue Nov 27 22:30:36 2012 -0700
    
        Added datasets from others
    

    Step 2: Then select the hash that commit hashes and see the commits made by other author.. For that you need to do this:

    $ git log <your commit after merge> -p -2

    Example:

    git log d8340ff -p -2

    commit d8340ffcac2293a1bd9958278290234724cb099a
    Author: Another author <[email protected]>
    Date:   Tue Nov 22 1:34:57 2012 -0700
    
        commit msg blah blah...
    
    
    diff --git a/.DS_Store b/.DS_Store
    new file mode 100644
    index 0000000..bb727a2
    Binary files /dev/null and b/.DS_Store differ
    diff --git a/Gemfile b/Gemfile
    old mode 100644
    new mode 100755
    index 853b35e..891f41e
    --- a/Gemfile
    +++ b/Gemfile
    @@ -1,12 +1,17 @@
     source 'https://rubygems.org'
    
    -gem 'rails', '3.2.6'
    +gem 'rails', '3.2.9'
    
     # Bundle edge Rails instead:
     # gem 'rails', :git => 'git://github.com/rails/rails.git'
    

    by doing this you will know all the changes that they have done...