stack overflow
stack overflow

Reputation: 187

Is there a differnce between tree and branch in this documentation?

git status says it gives you the status of the current tree.

However, I'm used to type:

git branch -v

to see what branches I have.

Are the docs using the terms interchangeably? (tree and branch)?

Upvotes: 1

Views: 50

Answers (2)

VonC
VonC

Reputation: 1323953

Before Git 2.30 (Q1 2021), the glossary described a branch as an "active" line of development, which is misleading---a stale and non-moving branch is still a branch.

See commit eef1cea (23 Nov 2020) by Sergey Organov (sorganov).
(Merged by Junio C Hamano -- gitster -- in commit c9f1f44, 14 Dec 2020)

glossary: improve "branch" definition

Signed-off-by: Sergey Organov

The old phrasing is at least questionable, if not wrong, as there are a lot of branches out there that didn't see active development for years, yet they are still branches, ready to become active again any time.

The description now begins with:

A "branch" is a line of development.

(no more "active")

It still differ from working tree, as torek explains: an old stale branch would still be there, no matter what the current working tree (set of files you want a status of) is.

Upvotes: 0

torek
torek

Reputation: 488053

No, these are quite different.

For a series of Git definitions of terms, see the gitglossary. Here you will find these definitions:

branch

    A "branch" is an active line of development. The most recent commit on a branch is referred to as the tip of that branch. The tip of the branch is referenced by a branch head, which moves forward as additional development is done on the branch. A single Git repository can track an arbitrary number of branches, but your working tree is associated with just one of them (the "current" or "checked out" branch), and HEAD points to that branch.

[snippage]

tree

    Either a working tree, or a tree object together with the dependent blob and tree objects (i.e. a stored representation of a working tree).

The notion of "branch" is defined oddly in Git, with respect to most if not all other Version Control Systems that exist anywhere in the world. See What exactly do we mean by "branch"?

The "tree" mentioned in git status documentation is specifically the "working tree" or "work-tree". The work-tree is pretty simple: it's where you do your work. The reason for this is that Git's internal storage for files is in a format usable only to Git itself. In order for all the other computer programs you have on your computer to work with files, and for you to work with them yourself, you need a work area, which is your "work-tree" or "working tree".

What's in your work-tree is not in Git at all. Only Git's internal files are in Git. The work-tree files may store the same data—but in normal, ordinary, every-day computing format—as some internal Git files, or they may not. The internal files are versioned, which is not specifically a Git term (and not mentioned in the Git glossary), but means that Git stores every version you ever asked it to store, more or less permanently,1 and in a form that never changes once stored. This means that once stored into the Git repository, you can get every version of every file you, or anyone else, ever stored.


1These versions are stored in commits, which are also mostly-permanent and entirely-unchangeable. Under some conditions, you can rid yourself of—i.e., strip out—some specific commits, but it's deliberately quite difficult (well, other than removing the entire repository, or wiping the hard drive / USB stick / whatever storage medium: but since Git repositories are routinely copied all over the Internet, there are probably 400 more copies Out There somewhere).

Upvotes: 1

Related Questions