svn - What's the meaning of git's snapshot of a file? -
i'm reading git basics
git thinks of data more set of snapshots of miniature filesystem
i not understanding meaning of snapshot of git. git store entire file content in each snapshot/version? example, version 1
#include <stdio.h> int main() { printf("hello, world"); return 0; }
in version 2 added line file.
#include <stdio.h> int main() { printf("hello, world"); printf("hello, git"); return 0; }
will git store entire content rather store difference(printf("hello, git")
) between these 2 versions svn etc?
if is, what's point?
will git store entire content rather store difference(printf("hello, git")) between these 2 versions svn etc?
git stores the entire contents of file. takes no space when file didn't change.
read brilliant answer git pack file format: are git's pack files deltas rather snapshots?
about sha1
files (and other stuff) stored in form of "blob". each sequence of bytes has own sha1-code, pretty unique it.
the following true sha1:
- sha1 calculation file gives same result @ time, os, git version or implementation.
- files different names or paths equal contents have equal sha1-s.
- if 2 files have different sha1-s, not equal probability of 1.
- if 2 files have equal sha1-s, equal probability of around 1 - 1 / 2400 (as remember) pretty 1.
what benefits system gives
- revisions can compared equality quick. no file contents checked, sha1-s.
- when push/pull, changed files transmitted.
- checking status of current changes done in moment.
- lets track n files equal contents, taking place of single file in git.
- changing revision in working tree quick.
- without applying consecutive patches
- you can exclude commits branch, pull them branch, change order.
about diff (and git diff):
you may have noticed git indeed shows diff of text files, pointing out added , removed lines. done diff utility convenience. helps collect contribution statistics. , used resolving merge conflicts. nevertheless git treats , stores text (and binary) files single blobs.
exclusion git add --patch
there way force git break text files chunks when staging changes. may useful large files, pretty useless small ones.
git add --patch
interactively choose hunks of patch between index , work tree , add them index. gives user chance review difference before adding modified contents index.
these favourite illustrations git pro git:
Comments
Post a Comment