I am a git novice trying to sort through the concepts 开发者_Go百科and terms. The git glossary says a tree is equivalent to a directory and a directory is what you get with ls. Are they interchangeable terms? Or are "tree" and "directory" to be used in different contexts or to refer to separate (though related) things?
The short answer: yes, a tree is a directory and a directory is a tree.
The long answer: A tree is an object that contains a list of blobs, the names to attach to the blobs, and other trees and the names to attach to them. http://book.git-scm.com/1_the_git_object_model.html has a pretty good explanation of the different object types in the git model; I would suggest reading it!
In Git terminology, a "tree" is a hierarchical structure of files and directories. This is (purposefully) very similar to a directory in a filesystem.
A Git commit object contains a reference to a tree object, which is the state of all files at the time of that commit.
- The Git Object Model
- All Git Object Types: Blob, Tree, Commit And Tag
To put it simply, the "tree" refers to the snapshot of the entire repository state at that moment in time (like what you've got for your current code [which is also known as HEAD], of the repository when the currently checked-out commit was made, etc.)
Directory is just referring to a filesystem directory.
精彩评论