views:

255

answers:

2

Hi,

After git pull, its output gives a summary on the change amount. If I want to see the detail change of each file or some file, how can I?

Thanks and regards!

Update:

Thanks. I am not sure why I cannot add comment or vote on your answers. Okay, here is my question to Jefromi:

  1. How do I know if I was pulling to master? All I did is "git pull".

  2. What does master point to and what is the difference between master and HEAD, the two default heads of git

  3. how to see the detail change in a specific file?

  4. how to see the change in summary output by last git pull again?

  5. what's difference between git diff and git-whatchanged?

+2  A: 

Suppose you're pulling to master. You can refer to the previous position of master by master@{1} (or even master@{10.minutes.ago}, see the specifying revisions section of the git-rev-parse man page), so that you can do things like

  • See all of the changes: git diff master master@{1}

  • See the changes to a given file: git diff master master@{1} <file>

  • See all the changes within a given directory: git diff master master@{1} <dir>

  • See the summary of changes again: git diff --stat master master@{1}

[Edited for clear descriptions of what each command does]

As for your question of "how do I know if I'm on master"... well, using branches is an important part of git workflow. You should always be aware of what branch you're on - if you pulled changes, you want to pull them to the right branch! You can see a list of all branches, with an asterisk by the currently checked-out one, with the command git branch. The current branch name is also printed along with the output of git status. I highly recommend skimming the man pages of commands to use - it's a great way to slowly pick up some knowledge.

And your last question: HEAD is the name for the currently checked out branch. You can indeed use HEAD and HEAD@{1} in this context as well, but it's a bit more robust to use the branches, since if you go and check out another branch, HEAD is now that second branch, and HEAD@{1} is now master - not what you want!

To save having to ask a lot of little questions like this, you should probably have a look at a git tutorial. There are a million on the web, for example:

Jefromi
this is better than my solution :)
Christian Oudard
+3  A: 

Say you do a git pull like this:

$ git pull
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 4), reused 0 (delta 0)
Unpacking objects: 100% (6/6), done.
From [email protected]:reponame
   a407564..9f52bed  branchname   -> origin/branchname
Updating a407564..9f52bed
Fast forward
 .../folder/filename          |  209 ++++++++-----
 .../folder2/filename2        |  120 +++++++++++---------
 2 files changed, 210 insertions(+), 119 deletions(-)

You can see the diff of what changed by using the revision numbers:

$ git diff a407564..9f52bed
Christian Oudard
And you can get the summary using "`git diff --stat a407564..9f52bed`" or for just a summary "`git diff --summary a407564..9f52bed`"
Jakub Narębski