What is the difference between a tree and a directory?

I am starting to start git, trying to understand the concepts and terms. The git glossary says that a tree is equivalent to a directory, and a directory is what you get with ls. Are they interchangeable terms? Or should the "tree" and the "directory" be used in different contexts or refer to separate (albeit related) things?

+6
source share
4 answers

Short answer: yes, a tree is a directory, and a directory is a tree.

Long answer: A tree is an object containing a list of blobs, names for attaching to blocks, and other trees and names for attaching them. http://book.git-scm.com/1_the_git_object_model.html has a pretty good explanation of the different types of objects in the git model; I would suggest reading it!

+3
source

In Git terminology, a β€œtree” is a hierarchical structure of files and directories. This (purposefully) is very similar to a directory in a file system.

A Git commit object contains a reference to a tree object, which is the state of all files at the time of commit.

+3
source

Simply put, a β€œtree” refers to a snapshot of the entire state of the repository at that point in time (for example, what you have for your current code [which is also known as HEAD], the repository, when the commit is currently made, etc. .)

The directory only refers to a file system directory.

-1
source

Source: https://habr.com/ru/post/889753/


All Articles