Git三个树

Git作为一个内容管理系统,管理着三个主要部分:HEAD指向当前分支的最后一个提交快照,Index是提议的下一次提交快照,而WorkingDirectory则是工作目录,用于编辑和测试更改。HEAD、Index和WorkingDirectory之间的差异分别反映了未暂存的更改、待提交的更改以及已提交的历史记录。
摘要由CSDN通过智能技术生成

Three Trees

An easier way to think about reset and checkout is through the mental frame of Git being a content manager
of three different trees.
By "tree" here, we really mean "collection of files", not specifically the data structure.

Git as a system manages and manipulates three trees in its normal operation:
HEAD: Last commit snapshot,next parent
Index: Proposed next commit snapshot
Working Directory: Sandbox
The HEAD
HEAD is the pointer to the current branch reference, which is in turn a pointer to the last commit made
on that branch.
It’s generally simplest to think of HEAD as the snapshot of your last commit on that branch.

The Index
The index is your proposed next commit.
We’ve also been referring to this concept as Git’s “Staging Area” as this is what Git looks at when you
run git commit.
git ls-files, shows you what your index currently looks like.
The index is not technically a tree structure,it’s actually implemented as a flattened manifest,but for
our purposes it’s close enough.

# 在Git中,working tree和working directory是指同一个概念
The Working Directory
Finally,you have your working directory(also commonly referred to as the “working tree”).
The other two trees store their content in an efficient but inconvenient manner, inside the .git folder.
The working directory unpacks them into actual files, which makes it much easier for you to edit them.
Think of the working directory as a sandbox, where you can try changes out before committing them to your
staging area (index) and then to history.
"Changes not staged for commit",because that entry differs between the index and the working directory.
"Changes to be committed",because the index and HEAD differ,that is,our proposed next commit is now different from our last commit. 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值