How it works...

The git gc command optimizes the repository by compressing file revisions and deleting objects that there are no references to. The objects can be commits, and so on. On an abandoned (deleted) branch, blobs from invocations of git add, commits discarded/redone with git commit --amend, or other commands can leave objects behind. Objects are, by default, already compressed with zlib when they are created and, when moved into the pack file, Git makes sure to only store the necessary changes. For example, if you change only a single line in a large file, storing the entire file in the pack file again would waste a bit of space. Instead, Git stores the latest file as a whole in the pack file and only the delta for the older version. This is pretty smart, as you are more likely to require the latest version of the file, and Git doesn't have to do delta calculations for this. This might seem like a contradiction to the information from Chapter 1, Navigating Git, where we learned that Git stores snapshots and not deltas. However, remember how the snapshot is made. Git hashes all of the file content in blobs, makes tree and commit objects, and the commit object describes the full tree state with the root-tree sha-1 hash. Storing objects inside the pack-files has no effect on the computation of the tree state. When you check out an earlier version of commit, Git makes sure the sha-1 hashes match the branch, commit, or tag you requested.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.108.11