吉特:什么是“工作树"?与“工作目录"相同吗? [英] Git: What is exactly a 'working tree'? Is the same as 'working directory'?

查看:47
本文介绍了吉特:什么是“工作树"?与“工作目录"相同吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读大量有关Git的文档,最近我一直在寻找工作树​​"的概念,但我不明白工作树"的确切含义.

I am reading lots of documentation about Git and recently I have been looking for "working tree" concept, but I don't understand what exactly a "working tree" is.

我找到了以下描述:什么是工作树?这似乎是最容易理解的.但是我不完全理解.

I have found this description: What is a working tree? that seems to be the easiest to understand. But I don't fully understand it.

在链接中,我可以阅读:

In the link I can read:

Git中的工作树是文件系统上的目录(及其文件和子目录)

The Working Tree in Git is a directory (and its files and subdirectories) on your file system

据我所知,工作树是计算机上的文件夹.正确的?到底是哪个文件夹?

So as far I can understand, the working tree is a folder on my computer. Right? Which folder exactly?

说明如下...

存储库相关联的

.

that is associated with a repository.

解释中的术语存储库是指本地存储库,任何人都可以在下图中看到它(蓝绿色矩形)?

The term repository in the explanation is refering to the local repository as anyone can see in the following picture (the blue-green rectangle)?

在这里,在stackoverflow中寻找类似的问题,我发现了这一点:工作树与工作目录

Looking for similar questions here, in stackoverflow, I have found this: Working tree vs working directory

格雷格(Greg)回答的第二个答案是:

The second answer, answered by Greg, says:

工作树表示包含.git文件夹的目录,包括所有子目录和文件.

Working tree means the directory that contains the .git folder, including all sub directories and files.

因此,我知道工作树与工作目录相同.正确的? 我的意思是,目录中包含我的项目的源代码,例如C:\ Richard \ Projects \ Calc \,在该目录中,我执行命令 git init (在\ Calc内部).

So I understand that working tree is the same as the working directory. Right? I mean, the directory I have the source code of my project, for example C:\Richard\Projects\Calc\ that is where I execute the command git init (inside \Calc).

我的理解正确吗?

推荐答案

官方词汇表定义了工作树为:

实际检出的文件树.
工作树通常包含HEAD提交树的内容,以及您已进行但尚未提交的所有本地更改.

The tree of actual checked out files.
The working tree normally contains the contents of the HEAD commit’s tree, plus any local changes that you have made but not yet committed.

它没有提到工作目录".

It does not mention "working directory".

我的意思是,目录中包含我的项目的源代码,例如C:\Richard\Projects\Calc\,这是我执行命令git init(在\Calc内部)的位置.

I mean, the directory I have the source code of my project, for example C:\Richard\Projects\Calc\ that is where I execute the command git init (inside \Calc).

不总是如此.

一棵工作树并不总是 里面有一个.git:

A working tree does not always have a .git in it:

  • either because the environment variable GIT_DIR is set (and references the actual path of the .git subfolder, which can be anywhere else)

,或者因为您已使用 git worktree 命令,允许您从一个克隆存储库中检出多个单独的工作目录中的多个分支:请参阅" Git?".

or because you have used the git worktree command, which allows you to checkout multiple branches in multiple separate working directories, from one cloned repository: see "Multiple working directories with Git?".

但是,如最后一条命令所示,工作目录"被用作工作树"的同义词.

But, as illustrated by that last command, "working directory" is used as a synonym from "working tree".

首选第二个:在Git的最开始,提交2a29da7 ( Git v0.99.5,2005年8月),Junio C. Hamano提到:

The second is preferred: in the very beginning of Git, commit 2a29da7 (Git v0.99.5, Aug. 2005), Junio C. Hamano mentioned:

始终使用工作树",对象名称",存储库"作为规范术语.

Use "working tree", "object name", "repository" as the canonical term consistently.

这篇关于吉特:什么是“工作树"?与“工作目录"相同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆