开发者

What is the difference between a tree and a directory?

开发者 https://www.devze.com 2023-03-10 13:57 出处:网络
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 interchangeabl

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消