Reputation: 347
I am a git novice trying to sort through the concepts 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?
Upvotes: 6
Views: 2207
Reputation: 11158
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!
Upvotes: 3
Reputation: 2946
Upvotes: 1
Reputation: 1224
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.
Upvotes: -1
Reputation: 994619
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.
Upvotes: 3