46

I'm trying to gain a more thorough understanding of git.

Can someone give me a simple line-by-line explanation of what basic git pull output means? Example:

remote: Counting objects: 11, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (7/7), done.
From ssh://my.remote.host.com/~/git/myproject
 * branch            master     -> FETCH_HEAD
Updating 9d447d2..f74fb21
Fast forward
 app/controllers/myproject_controller.rb |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
slabserif23
  • 475
  • 4
  • 5

1 Answers1

71

Under the hood, git pull is git fetch followed by git merge. Here's the fetch portion:

remote: Counting objects: 11, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 7 (delta 2), reused 0 (delta 0)

At this point, you've told the remote what you want. It finds all the objects it needs to give you (counting them in the process, I believe), compresses them for faster transfer over the network, and then reports what it's sending you. Objects may be blobs, trees, commits, or tags - see for example the git book for more information.

Unpacking objects: 100% (7/7), done.

You receive the pack (set of compressed objects) and unpack it.

From ssh://my.remote.host.com/~/git/myproject
 * branch            master     -> FETCH_HEAD

You've fetched the branch 'master' from the given remote; the ref FETCH_HEAD now points to it. Now we move on to the merge - precisely, git will merge FETCH_HEAD (the remote's master branch) into your current branch (presumably master).

Updating 9d447d2..f74fb21
Fast forward

It turns out that you haven't diverged from the remote's master branch, so the merge is a fast-forward (a trivial merge where it simply moves you forward in the history). Git notes the original position of your master branch (9d447d2) and the new position (f74fb21) it's been fast-forwarded to. If you had diverged from the remote's master branch, you'd see the output of a recursive merge here - Merge made by recursive, possibly along with some Auto-merged <file> and (oh no!) merge conflicts!

 app/controllers/myproject_controller.rb |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

Finally, it shows you the diffstat between the original and post-merge position of your master branch; this is basically what you'd get from git diff --stat master@{1} master.

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
Cascabel
  • 479,068
  • 72
  • 370
  • 318
  • +1 "It turns out that you haven't diverged from the remote's master branch" - you mean no new branch has been created? Also what does ++ or -- mean – Aravind Yarram Jul 11 '13 at 03:19
  • 3
    @Pangea and others who might be wondering in the future: No it doesn't mean that no new branch was created, it simply means that you didn't concurrently committed changes that weren't yet included in the remote branch. In this case, there is nothing to merge, you simply add the new commits on top of your local branch and both your local branch and the remote branch will be identical. The ++ and -- are simply "graphical" representations of the amount of changes in each file (+'s being insertions and -'s being deletions) and thus tell you roughly where most of the changes went to. – tne Nov 28 '14 at 10:08