0

Git documentation states:

Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment

What does it basically mean "to take a picture"?

Mandroid
  • 6,200
  • 12
  • 64
  • 134
  • See also http://stackoverflow.com/a/8198276/6309 – VonC Jun 17 '16 at 07:15
  • Where exactly in the documentation? – 1615903 Jun 17 '16 at 07:18
  • 1
    This accepted answer: https://stackoverflow.com/questions/33455666/git-why-exactly-is-the-claim-git-is-based-on-differences-between-files-wrong/33455768#33455768 has a good summary of what is a git commit internally. – Julien Lopez Jun 17 '16 at 07:19
  • link:https://git-scm.com/book/en/v2/Getting-Started-Git-Basics – Mandroid Jun 17 '16 at 07:27
  • In other words it takes a snapshot. That means that it saves the state of all files staged for the commit (files added to the index - e.g. with `git add`). – René Link Jun 17 '16 at 07:31

2 Answers2

0

It asks all the files in the repository to stand in a line and say "cheese". Then, an x-ray picture is taken, showing all the binary data.

This binary data is then used to determine the state at which your folder was at that point, in order to re-create it later (on a different location) or to make diff's.

JefGli
  • 781
  • 3
  • 15
0

Make a commit and then run git log -1 --pretty=raw and you will see tree xxxxxx in the output. The tree is the sha1 of a snapshot of the current git repo . If two trees have the same sha1, we can be sure they have the same contents. You could run git ls-tree sha1 to see what's the tree composed of or what the snapshot has. You will see a list of trees and blobs, sometimes also commits, with their sha1s. A blob refers to a file. A tree refers to a folder. You could run git cat-file -p blob-sha1 or git show blob-sha1 to see the content of the blob. Every blob is a snapshot of a file in different times. If a file is changed, its blob and sha1 changes too. But with the same content, we can always get the same sha1, by git hash-object. So basically, a commit refers to a tree (the root folder of the git repo) which represents the state of the git repo. A tree is composed of other trees (sub directories) and blobs (files) in the git repo. When we make a commit, it records the state of the git repo, what the folders and files are like at that time. With the commit, we can rebuild the whole git repo which is described by the trees and blobs.

ElpieKay
  • 27,194
  • 6
  • 32
  • 53