官术网_书友最值得收藏!

Introduction

In this chapter, we will take a look at Git's data model. We will learn how Git references its objects and how the history is recorded. We will learn how to navigate the history, from finding certain text snippets in commit messages to the introduction of a certain string in the code.

The data model of Git is different from other common version control systems (VCSs) in the way Git handles its data. Traditionally, a VCS will store its data as an initial file followed by a list of patches for each new version of the file.

Git is different; instead of the regular file and patches list, Git records a snapshot of all the files tracked by Git and their paths relative to the repository root, that is, the files tracked by Git in the file system tree. Each commit in Git records the full tree state. If a file does not change between commits, Git will not store the file once more; instead, Git stores a link to the file.

This is what makes Git different from most other VCSs, and in the following chapters, we will explore some of the benefits of this powerful model.

The way Git references the files and directories it tracks is directly built into the data model. In short, the Git data model can be summarized as shown in the following diagram:

The commit object points to the root tree. The root tree points to subtrees and files. Branches and tags point to a commit object and the HEAD object points to the branch that is currently checked out. So for every commit, the full tree state and snapshot are identified by the root tree.

主站蜘蛛池模板: 南丹县| 清丰县| 防城港市| 阿勒泰市| 买车| 乌拉特后旗| 鹤庆县| 长武县| 嘉峪关市| 湟中县| 东莞市| 嘉鱼县| 全椒县| 土默特右旗| 城步| 万宁市| 南部县| 榕江县| 江达县| 志丹县| 盐城市| 五华县| 宝鸡市| 中卫市| 格尔木市| 焦作市| 瓦房店市| 宁城县| 麦盖提县| 新津县| 河北省| 姜堰市| 会同县| 张北县| 蓬莱市| 诏安县| 永平县| 广州市| 永登县| 马关县| 海口市|