Git三个树

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. 

猜你喜欢

转载自blog.csdn.net/qq_53318060/article/details/131355489
今日推荐