Reputation: 23445
After doing a git pull, what is the command to see what changed in the files that got updated? examples would be great.
Upvotes: 1
Views: 89
Reputation: 363487
git pull
will by default report something like
Updating 9e9a656..bb743dd
which is valid input to git log
or git diff
:
git log -p 9e9a656..bb743dd
git diff 9e9a656..bb743dd
If you lost the git pull
output, you can use git reflog
to review your own actions:
bb743dd HEAD@{0}: pull origin master: Fast-forward
9e9a656 HEAD@{1}: reset: moving to HEAD^
So in this case, git log HEAD@{1}
will also show the contents of the pull, and if you did anything in between (such as a commit
)...
1dac876 HEAD@{0}: commit: some stuff
bb743dd HEAD@{1}: pull origin master: Fast-forward
9e9a656 HEAD@{2}: reset: moving to HEAD^
... you can use the ..
syntax:
git log HEAD@{2}..HEAD@{1} # or log -p, or diff
Upvotes: 4
Reputation: 139421
You want to see the files that changed in the last pull. That’s
git diff --name-only HEAD@{1}..HEAD
The git rev-parse
documentation explains.
<refname>
@{
<n>}
, e.g.,master@{1}
A ref followed by the suffix
@
with an ordinal specification enclosed in a brace pair (e.g.,{1}
,{15}
) specifies the n-th prior value of that ref. For examplemaster@{1}
is the immediate prior value of master whilemaster@{5}
is the 5th prior value of master. This suffix may only be used immediately following a ref name and the ref must have an existing log ($GIT_DIR/logs/<refname>
).
Running git pull
moves the current branch. HEAD
is where it is now, and HEAD@{1}
is where it was before the pull.
To see one–character summaries of how the files changed, run
git diff --name-status HEAD@{1}..HEAD
The full details are available in the output of
git diff HEAD@{1}..HEAD
Upvotes: 0
Reputation: 18520
[The following answer assumes that the merge was not a fast-forward merge, and that you didn't ask git pull
to use its rebase mode. In case those assumptions are wrong, probably either git log
or git log -p
or git diff HEAD@{1} HEAD
will show you what you want.]
There's two different things you can do: review which commits got merged, and review the changes introduced by the merge. The former is done using git log
(as explained in another answer); the latter is a bit more complicated.
Normally, git show <commit>
gives you a diff of stuff introduced in the given commit, but for merge commits this produces a reduced "combined diff". The specifics are not terribly relevant here... suffice to say that you won't see a normal diff for merge commits unless you use trickery.
The easiest way to see a diff of the changes introduced by a merge (and any conflict resolution performed as part of it), as compared to the first parent, is git diff <commit>^ <commit>
(^
= first parent).
For maximum detail, you can look at the diffs of the individual commits that got merged. I recommend doing this in graph view, making the whole thing slightly less intangible: git log --graph -p
Upvotes: 0
Reputation: 2028
I would use git log
to view the commit messages (and SHAs), and git diff <SHA-commitA> HEAD
, where is the last commit you had before pull
-ing.
Upvotes: 1