Detail change after Git pull

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@{1} master

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

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

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

As for your question of “how do I know if I’m on master”… well, using branches is an important part of the 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:

  • The Pro Git book
  • Git Magic
  • and the 4.5 million hits on Google for “Git tutorial”

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)