Skip to main content

The Anatomy of a Git Pull

Ever seen something like this?

➜  ~/projects/gitblit/[master]>git pull
remote: Counting objects: 5899, done.
remote: Compressing objects: 100% (1322/1322), done.
remote: Total 5746 (delta 4099), reused 5413 (delta 3770)
Receiving objects: 100% (5746/5746), 3.78 MiB | 853 KiB/s, done.
Resolving deltas: 100% (4099/4099), completed with 98 local objects.
From git://github.com/gitblit/gitblit
 * [new branch]      bootstrap  -> origin/bootstrap
 * [new branch]      gh-pages   -> origin/gh-pages
 * [new branch]      issues     -> origin/issues
 * [new branch]      ldap       -> origin/ldap
   8f73a7c..67d4f89  master     -> origin/master
 * [new branch]      rpc        -> origin/rpc
From git://github.com/gitblit/gitblit
 * [new tag]         v0.9.1     -> v0.9.1
 * [new tag]         v0.9.2     -> v0.9.2
 * [new tag]         v0.9.3     -> v0.9.3
Updating 8f73a7c..67d4f89
Fast-forward
 .classpath                                         |  137 +-
 .gitignore                                         |   43 +-
 NOTICE                                             |   56 +
 build.xml                                          |  484 ++-
 distrib/add-indexed-branch.cmd                     |   20 +
[..clipped..]
 docs/screenshots/00.png                            |  Bin 41019 -> 38869 bytes
 374 files changed, 43257 insertions(+), 3508 deletions(-)
 create mode 100644 distrib/add-indexed-branch.cmd
 create mode 100644 distrib/federation.properties
[..clipped..]

Well, David Gerber on the Git-user mailing list did, and asked what all this output is about. I realized it that I've built up a mental filter on the output of many Git commands, ignoring the parts which aren't important. So I wanted to dig in there, understand and explain each of those lines. Here's a slightly adapted copy of my answer on the mailing list. I'll update it if you have any comments that can improve on the explanations.

I've swapped his example output with what I got from doing a large update in the Gitblit project:


➜  ~/projects/gitblit/[master]>git pull remote: Counting objects: 5899, done.
Any message prefixed with "remote:" means it's coming from the remote repository.

The first thing it does it to count the number of objects in the repository that will have to be transferred: commits, blobs, trees and tags. 5899 is the number of objects missing in your local repository, I believe.

If you want to find out more about these objects, try playing around with git count-objects -v in your repositories, before and after committing. Also note how git gc modifies the result.

Note that the object count differs between "loose" objects, and objects that have been compressed into "pack files" (think of it as zip files) for efficiency.

remote: Compressing objects: 100% (1322/1322), done.
This is the remote compressing loose objects before transfer. I reckon 1322 is the number of loose objects that need to be transferred.

remote: Total 5746 (delta 4099), reused 5413 (delta 3770)
Now here I'm getting a bit unsure. Git does a lot of optimization on making the transfer as fast as possible. Some of the compressions it has done are delta-compressed, and I reckon that's what those delta objects are. I think reused means the contents that were already compressed into pack files on the remote side. Closest thing I could find to an explanation is here.

Receiving objects: 100% (5746/5746), 3.78 MiB | 853 KiB/s, done.
This is just a progress counter during the transfer across the wire. The final 38.50 is the number of Kibibytes (analog to Kilobytes) that was transferred.

Resolving deltas: 100% (4099/4099), completed with 98 local objects.
Just the receiving end confirming the deltas mentioned above.


From git://github.com/gitblit/gitblit
* [new branch] bootstrap -> origin/bootstrap
* [new branch] gh-pages -> origin/gh-pages
* [new branch] issues -> origin/issues
* [new branch] ldap -> origin/ldap
8f73a7c..67d4f89 master -> origin/master
* [new branch] rpc -> origin/rpc


This is a summary of the changes in the remote branches. Most of them are new, but you were already tracking the branch master, so it says from which version it was updated , and which it was updated to (from..to).



From git://github.com/gitblit/gitblit
* [new tag] v0.9.1 -> v0.9.1
* [new tag] v0.9.2 -> v0.9.2
* [new tag] v0.9.3 -> v0.9.3

Easy enough, these are the new tags that have been created.

Konstantin Khomoutov adds: Worth mentioning that only the tags attached to objects which are
referenced (directly or indirectly) by the head(s) being fetched (`git
pull` calls `git fetch` first) are downloaded by default. 
To get all the tags from the remote one can use `git fetch --tags ...`

Updating 8f73a7c..67d4f89
This is your current active branch (master) being updated with the changes we saw earlier. Since you are pulling, and not simply fetching, the changes from the remote branch are being merged into your local branch (because your local branch 'master' is set up to track the remote branch 'origin/master').

Fast-forward
This means that your local branch has not diverged from origin/master. In other words: you haven't made any local commits. The merge can therefore be fast-forwarded, playing the changes onto your local branch without doing a merge commit.

Note: This is an important line! If your pull was not a fast-forward, it means a merge commit has been created for you. If this is not intentional, you should consider undoing the merge (git reset --hard HEAD~1), and then doing git pull --rebase instead.

 .classpath                                         |  137 +-
 .gitignore                                         |   43 +-
 NOTICE                                             |   56 +
 build.xml                                          |  484 ++-
 distrib/add-indexed-branch.cmd                     |   20 +

These are the changes in "stat" form (lines added minus lines removed - same as doing git diff --stat 8f73a7c..67d4f89).

 docs/fed_aggregation.png        |  Bin 0 -> 21532 bytes
Change in a binary file, cannot be expressed as line changes, so the change in size is printed instead

 374 files changed, 43257 insertions(+), 3508 deletions(-)
A summary of the changes that were made in your local branch.

 create mode 100644 distrib/add-indexed-branch.cmd
 create mode 100644 distrib/federation.properties
[..clipped..]
This is a notice on which of the changes files are actually new files.

If you can elaborate any more on any of these, please do so in a comment, and I'll extend the post.

Comments

Popular posts from this blog

Open source CMS evaluations

I have now seen three more or less serious open source CMS reviews. First guy to hit the field was Matt Raible ( 1 2 3 4 ), ending up with Drupal , Joomla , Magnolia , OpenCms and MeshCMS being runner-ups. Then there is OpenAdvantage that tries out a handful ( Drupal , Exponent CMS , Lenya , Mambo , and Silva ), including Plone which they use for their own site (funny/annoying that the entire site has no RSS-feeds, nor is it possible to comment on the articles), following Matt's approach by exluding many CMS that seem not to fit the criteria. It is somewhat strange that OpenAdvantage cuts away Magnolia because it "Requires J2EE server; difficult to install and configure; more of a framework than CMS", and proceed to include Apache Lenya in the full evaluation. Magnolia does not require a J2EE server. It runs on Tomcat just like Lenya does (maybe it's an idea to bundle Magnolia with Jetty to make it seem more lightweight). I'm still sure that OpenAdvant...

Encrypting and Decrypting with Spring

I was recently working with protecting some sensitive data in a typical Java application with a database underneath. We convert the data on its way out of the application using Spring Security Crypto Utilities . It "was decided" that we'd be doing AES with a key-length of 256 , and this just happens to be the kind of encryption Spring crypto does out of the box. Sweet! The big aber is that whatever JRE is running the application has to be patched with Oracle's JCE  in order to do 256 bits. It's a fascinating story , the short version being that U.S. companies are restricted from exporting various encryption algorithms to certain countries, and some countries are restricted from importing them. Once I had patched my JRE with the JCE, I found it fascinating how straight forward it was to encrypt and decrypt using the Spring Encryptors. So just for fun at the weekend, I threw together a little desktop app that will encrypt and decrypt stuff for the given password...

The Git Users Mailing List

A year ago or so, I came across the Git-user mailing list (aka. "Git for human beings"). Over the year, I grew a little addicted to helping people out with their Git problems. When the new git-scm.com webpage launched , and the link to the mailing list had disappeared, I was quick to ask them to add it again . I think this mailing list fills an important hole in the Git community between: The Git developer mailing list git@vger.kernel.org  - which I find to be a bit too hard-core and scary for Git newbies. Besides, the Majordomo mailing list system is pretty archaic, and I personally can't stand browsing or searching in the Gmane archives. The IRC channel #git on Freenode, which is a bit out-of-reach for people who never experienced the glory days of IRC. Furthermore, when the channel is busy, it's a big pain to follow any discussion. StackOverflow questions tagged git , these come pretty close, but it's a bit hard to keep an overview of what questio...

Git tools for keeping patches on top of moving upstreams

At work, we maintain patches for some pretty large open source repositories that regularly release new versions, forcing us to update our patches to match. So far, we've been using basic Git operations to transplant our modifications from one major version of the upstream to the next. Every time we make such a transplant, we simply squash together the modifications we made in the previous version, and land it as one big commit into the next version. Those who are used to very stringent keeping of Git history may wrinkle their nose at this, but it is a pragmatic choice. Maintaining modifications on top of the rapidly changing upstream is a lot of work, and so far we haven't had the opportunity to figure out a more clever way to do it. Nor have we really suffered any consequences of not having an easy to read history of our modifications - it's a relatively small amount of patches, after all. With a recent boost in team size, we may have that opportunity. Also the need for be...

Managing dot-files with vcsh and myrepos

Say I want to get my dot-files out on a new computer. Here's what I do: # install vcsh & myrepos via apt/brew/etc vcsh clone https://github.com/tfnico/config-mr.git mr mr update Done! All dot-files are ready to use and in place. No deploy command, no linking up symlinks to the files . No checking/out in my entire home directory as a Git repository. Yet, all my dot-files are neatly kept in fine-grained repositories, and any changes I make are immediately ready to be committed: config-atom.git     -> ~/.atom/* config-mr.git     -> ~/.mrconfig     -> ~/.config/mr/* config-tmuxinator.git       -> ~/.tmuxinator/* config-vim.git     -> ~/.vimrc     -> ~/.vim/* config-bin.git        -> ~/bin/* config-git.git               -> ~/.gitconfig config-tmux.git       -> ~/.tmux.conf     config...