{"thread":{"id":"42662","subject":"Fwd: what is a snapshot?","startedAt":"2016-06-19T14:15:24Z","lastAt":"2016-06-29T19:37:25Z","messageCount":4,"participants":["Ovatta Bianca","Philip Oakley","Jeff King","Jakub Narębski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"289624","messageId":"CAHWPVgMWeHoD5vTiFJ1gsm2hS74LK7j4npVVbOZeR43cX3qWXw@mail.gmail.com","threadId":"42662","inReplyTo":"CAHWPVgNrTEw9FmW6K7QucgA74QWsTKfxZGt+mGd099k+O7O+rw@mail.gmail.com","subject":"Fwd: what is a snapshot?","fromName":"Ovatta Bianca","fromEmail":"ovattabianca@gmail.com","sentAt":"2016-06-19T14:15:20Z","receivedAt":"2016-06-19T14:15:24Z","isPatch":false,"sender":{"key":"ovattabianca@gmail.com","avatar":null},"body":"I read in every comparison of git vs other version control systems,\nthat git does not record differences but takes \"snapshots\"\nI was wondering what a \"snapshot\" is ? Does git store at every commit\nthe entire files which have been modified even if only a few bytes\nwere changed out of a large file?\n\nthank you\n"},{"id":"289627","messageId":"F6172B8DA802476C863849DEA02684A7@PhilipOakley","threadId":"42662","inReplyTo":"CAHWPVgMWeHoD5vTiFJ1gsm2hS74LK7j4npVVbOZeR43cX3qWXw@mail.gmail.com","subject":"Re: what is a snapshot?","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2016-06-19T15:20:14Z","receivedAt":"2016-06-19T15:23:06Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Ovatta Bianca\" <ovattabianca@gmail.com>\n>I read in every comparison of git vs other version control systems,\n> that git does not record differences but takes \"snapshots\"\n> I was wondering what a \"snapshot\" is ? Does git store at every commit\n> the entire files which have been modified even if only a few bytes\n> were changed out of a large file?\n>\nA snaphot is like a tar or zip of all your tracked files. This means it is \neasier to determine (compared to lots of diffs) the current content.\n\nKeeping all the snapshots as separate loose items, when the majority of \ntheir content is unchanged would be very inefficient, so git then uses, at \nthe right time, an efficient (and obviously lossless) compression technique \nto 'zip' all the snapshots together so that the final repository is \n'packed'. The overall effect is a very efficient storage scheme.\n\nThere are some good explanations on the web, such as the\nhttps://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain\nthough you may want to scan from the beginning ;-)\n\n--\n Philip \n\n"},{"id":"290024","messageId":"20160624153647.GA2448@sigill.intra.peff.net","threadId":"42662","inReplyTo":"F6172B8DA802476C863849DEA02684A7@PhilipOakley","subject":"Re: what is a snapshot?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-06-24T15:36:47Z","receivedAt":"2016-06-24T15:36:53Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Jun 19, 2016 at 04:20:14PM +0100, Philip Oakley wrote:\n\n> From: \"Ovatta Bianca\" <ovattabianca@gmail.com>\n> > I read in every comparison of git vs other version control systems,\n> > that git does not record differences but takes \"snapshots\"\n> > I was wondering what a \"snapshot\" is ? Does git store at every commit\n> > the entire files which have been modified even if only a few bytes\n> > were changed out of a large file?\n> > \n> A snaphot is like a tar or zip of all your tracked files. This means it is\n> easier to determine (compared to lots of diffs) the current content.\n> \n> Keeping all the snapshots as separate loose items, when the majority of\n> their content is unchanged would be very inefficient, so git then uses, at\n> the right time, an efficient (and obviously lossless) compression technique\n> to 'zip' all the snapshots together so that the final repository is\n> 'packed'. The overall effect is a very efficient storage scheme.\n> \n> There are some good explanations on the web, such as the\n> https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain\n> though you may want to scan from the beginning ;-)\n\nI think the delta compression is only half the story.\n\nEach commit is a snapshot in that it points to the sha1 of the root\ntree, which points to the sha1 of other trees and blobs. And following\nthat chain gives you the whole state of the tree, without having to care\nabout other commits.\n\nAnd if the next commit changes only a few files, the sha1 for all the\nother files will remain unchanged, and git does not need to store them\nagain. So already, before any explicit compression has happened, we get\nde-duplication of identical content from commit to commit, at the file\nand tree level.\n\nAnd then when a file does change, we store the whole new version, then\ndelta compress it during \"git gc\", etc, as you describe.\n\n-Peff\n"},{"id":"290523","messageId":"57742174.9020309@gmail.com","threadId":"42662","inReplyTo":"CAHWPVgMWeHoD5vTiFJ1gsm2hS74LK7j4npVVbOZeR43cX3qWXw@mail.gmail.com","subject":"Re: Fwd: what is a snapshot?","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-06-29T19:28:52Z","receivedAt":"2016-06-29T19:37:25Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 2016-06-19 o 16:15, Ovatta Bianca pisze:\n\n> I read in every comparison of git vs other version control systems,\n> that git does not record differences but takes \"snapshots\"\n> I was wondering what a \"snapshot\" is ? Does git store at every commit\n> the entire files which have been modified even if only a few bytes\n> were changed out of a large file?\n\nThere are two things: the conceptual level, and actual storage. On the\nconceptual level, object representing revisions (commit) refer to\nobject representing top directory (tree) of a project, that is a snapshot\nof a project state at given revision.\n\nOn the storage level, Git has two types of object storage. In \"loose\"\nformat (used for new objects), each object is stored as a separate\nfile. This is not as wasteful as you think: first, there is deduplication,\nthat is each version of a file is stored only once. Second, contents\n(usually text) is stored compressed.\n\nIn \"packed\" format (nowadays Git automatically repacks from \"loose\"\nto \"packed\" when it looks like it is needed) there is additional\nlibxdiff-like deltafication. In this format Git stores differences\n(well, it also ensures that delta chain doesn't gets too long).\n\nHTH\n-- \nJakub Narębski\n\n"}]}