How does git track file changes internally?

前端 未结 5 1974
孤街浪徒
孤街浪徒 2021-02-12 16:10

Could somebody explain how git knows internally that files X, Y and Z have changed? What is the process behind the scenes that recognizes when a file has not yet been added or h

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-12 16:32

    I found this article very helpful.

    https://codewords.recurse.com/issues/two/git-from-the-inside-out

    Git is built on a graph. Almost every Git command manipulates this graph. To understand Git deeply, focus on the properties of this graph, not workflows or commands.

    Extract - Make a commit that is not the first commit

    The user sets the content of data/number.txt to 2. This updates the working copy, but leaves the index and HEAD commit as they are.

    The user adds the file to Git. This adds a blob containing 2 to the objects directory. It points the index entry for data/number.txt at the new blob.

提交回复
热议问题