Reputation: 149
I have pulled and merged code.
I want to see the changes which will be applied to the code.
Unfortunately, all of the following ones show also changes which are performed by other developer (these changes have been pulled some time ago)
git diff origin/ContactList...ContactList git diff origin/ContactList..ContactList git diff origin/ContactList...HEAD git diff origin/ContactList..HEAD
In other words, i have cloned the repo. I have pulled during the development process (i did want to be up-to-date). Now, i want to see my changes only.
P.S.: I did not create another branch
Upvotes: 1
Views: 1784
Reputation: 51935
git diff
shows you exactly what you ask it to show, which is the difference between the two commits you give it.
To find out how to see "only your own changes", you have to understand where in the history of a merge the upstream changes come in. This is easily done when looking at your history in some graphic representation, e.g. by using gitk
or git log --graph --oneline --decorate
, or some other history browser you like.
Assuming you have a "simple" situation in which two parallel lines of development (yours and upstream) were merge, your history will look something like this:
... <- A <- B <- U1 <- U2 <- ... <- Un <-+- C <-- D <-- ....
^ |
`--- Y1 <- Y2 <- ... <- Ym <-'
In this representation, the arrows go from child commits to their parents, so on the left side are older commits, and on the right side newer ones. (Your branch tip is somewhere on the right of C). The U*
commits represent upstream changes and the Y*
commits your own, though that is not very relevant.
The names used for these commits are symbolic; when actually calling the diff in your repo, you will need to use the actual ref names (tags or branches, if they exist in the right place, or commit SHAs otherwise).
To view all accumulated changes that happened on your own part of the merge (the Y*
commits), you can use
git diff B Ym
That is, the diff between the merge-base (last common commit) and your latest commit before the merge.
The way you tried it included the actual merge commit (C
in this example), which already contains all upstream changes, because by that point the merge already happened (this is literally the point of a merge commit).
A diff of somewhere before the merge and somewhere after it (including the merge commit) will thus include all changes of both sides of the merge.
Upvotes: 4