Skip to content

Commit 0ea05a1

Browse files
committed
Merge pull request #149 from qinglangee/t10_9
Translate 10-git-internals environment
2 parents 724ab02 + 185dddb commit 0ea05a1

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

book/10-git-internals/sections/environment.asc

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,138 @@
1-
=== Environment Variables
1+
=== 环境变量
22

3-
Git always runs inside a `bash` shell, and uses a number of shell environment variables to determine how it behaves.
4-
Occasionally, it comes in handy to know what these are, and how they can be used to make Git behave the way you want it to.
5-
This isn't an exhaustive list of all the environment variables Git pays attention to, but we'll cover the most useful.
3+
Git 总是在一个 `bash` shell 中运行,并借助一些 shell 环境变量来决定它的运行方式。
4+
有时候,知道它们是什么以及它们如何让 Git 按照你想要的方式去运行会很有用。
5+
这里不会列出所有的 Git 环境变量,但我们会涉及最有的那部分。
66

77

8-
==== Global Behavior
8+
==== 全局行为
99

10-
Some of Git's general behavior as a computer program depends on environment variables.
10+
像通常的程序一样,Git 的常规行为依赖于环境变量。
1111

12-
*`GIT_EXEC_PATH`* determines where Git looks for its sub-programs (like `git-commit`, `git-diff`, and others).
13-
You can check the current setting by running `git --exec-path`.
12+
*`GIT_EXEC_PATH`* 决定 Git 到哪找它的子程序 (像 `git-commit`, `git-diff` 等等)。
13+
你可以用 `git --exec-path` 来查看当前设置.
1414

15-
*`HOME`* isn't usually considered customizable (too many other things depend on it), but it's where Git looks for the global configuration file.
16-
If you want a truly portable Git installation, complete with global configuration, you can override `HOME` in the portable Git's shell profile.
15+
通常不会考虑修改 *`HOME`* 这个变量(太多其它东西都依赖它),这是 Git 查找全局配置文件的地方。
16+
如果你想要一个包括全局配置的真正的便携版 Git, 你可以在便携版 Git 的 shell 配置中覆盖 `HOME` 设置。
1717

18-
*`PREFIX`* is similar, but for the system-wide configuration.
19-
Git looks for this file at `$PREFIX/etc/gitconfig`.
18+
*`PREFIX`* 也类似,除了用于系统级别的配置。
19+
Git `$PREFIX/etc/gitconfig` 查找此文件.
2020

21-
*`GIT_CONFIG_NOSYSTEM`*, if set, disables the use of the system-wide configuration file.
22-
This is useful if your system config is interfering with your commands, but you don't have access to change or remove it.
21+
如果设置了 *`GIT_CONFIG_NOSYSTEM`*,就禁用系统级别的配置文件。
22+
这在系统配置影响了你的命令,而你又无权限修改的时候很有用。
2323

24-
*`GIT_PAGER`* controls the program used to display multi-page output on the command line.
25-
If this is unset, `PAGER` will be used as a fallback.
24+
*`GIT_PAGER`* 控制在命令行上显示多页输出的程序。
25+
如果这个没有设置,就会用 `PAGER` .
2626

27-
*`GIT_EDITOR`* is the editor Git will launch when the user needs to edit some text (a commit message, for example).
28-
If unset, `EDITOR` will be used.
27+
*`GIT_EDITOR`* 当用户需要编辑一些文本(比如提交信息)时, Git 会启动这个编辑器。
28+
如果没设置,就会用 `EDITOR`
2929

3030

31-
==== Repository Locations
31+
==== 版本库位置
3232

33-
Git uses several environment variables to determine how it interfaces with the current repository.
33+
Git 用了几个变量来确定它如何与当前版本库交互。
3434

35-
*`GIT_DIR`* is the location of the `.git` folder.
36-
If this isn't specified, Git walks up the directory tree until it gets to `~` or `/`, looking for a `.git` directory at every step.
35+
*`GIT_DIR`* `.git` 目录的位置.
36+
如果这个没有设置, Git 会按照目录树逐层向上查找 `.git` 目录,直到到达 `~` `/`
3737

38-
*`GIT_CEILING_DIRECTORIES`* controls the behavior of searching for a `.git` directory.
39-
If you access directories that are slow to load (such as those on a tape drive, or across a slow network connection), you may want to have Git stop trying earlier than it might otherwise, especially if Git is invoked when building your shell prompt.
38+
*`GIT_CEILING_DIRECTORIES`* 控制查找 `.git` 目录的行为。
39+
如果你访问加载很慢的目录(如那些磁带机上的或通过网络连接访问的),你可能会想让 Git 早点停止尝试,尤其是 shell 构建时调用了 Git
4040

41-
*`GIT_WORK_TREE`* is the location of the root of the working directory for a non-bare repository.
42-
If not specified, the parent directory of `$GIT_DIR` is used.
41+
*`GIT_WORK_TREE`* 是非空版本库的工作目录的根路径
42+
如果没指定,就使用 `$GIT_DIR` 的父目录。
4343

44-
*`GIT_INDEX_FILE`* is the path to the index file (non-bare repositories only).
44+
*`GIT_INDEX_FILE`* 是索引文件的路径(只有非空版本库有)
4545

46-
*`GIT_OBJECT_DIRECTORY`* can be used to specify the location of the directory that usually resides at `.git/objects`.
46+
*`GIT_OBJECT_DIRECTORY`* 用来指定 `.git/objects` 目录的位置。
4747

48-
*`GIT_ALTERNATE_OBJECT_DIRECTORIES`* is a colon-separated list (formatted like `/dir/one:/dir/two:…`) which tells Git where to check for objects if they aren't in `GIT_OBJECT_DIRECTORY`.
49-
If you happen to have a lot of projects with large files that have the exact same contents, this can be used to avoid storing too many copies of them.
48+
*`GIT_ALTERNATE_OBJECT_DIRECTORIES`* 一个冒号分割的列表 (格式类似 `/dir/one:/dir/two:…`) 用来告诉 Git 到哪里去找不在 `GIT_OBJECT_DIRECTORY` 目录中的对象.
49+
如果你有很多项目有相同内容的大文件,这个可以用来避免存储过多备份。
5050

5151

52-
==== Pathspecs
52+
==== 路径规则
5353

54-
A ``pathspec'' refers to how you specify paths to things in Git, including the use of wildcards.
55-
These are used in the `.gitignore` file, but also on the command-line (`git add *.c`).
54+
所谓 ``pathspec'' 是指你在 Git 中如何指定路径, 包括通配符的使用。
55+
它们会在 `.gitignore` 文件中用到,命令行里也会用到 (`git add *.c`)。
5656

57-
*`GIT_GLOB_PATHSPECS` and `GIT_NOGLOB_PATHSPECS`* control the default behavior of wildcards in pathspecs.
58-
If `GIT_GLOB_PATHSPECS` is set to 1, wildcard characters act as wildcards (which is the default); if `GIT_NOGLOB_PATHSPECS` is set to 1, wildcard characters only match themselves, meaning something like `*.c` would only match a file _named_ ``*.c'', rather than any file whose name ends with `.c`.
59-
You can override this in individual cases by starting the pathspec with `:(glob)` or `:(literal)`, as in `:(glob)*.c`.
57+
*`GIT_GLOB_PATHSPECS` and `GIT_NOGLOB_PATHSPECS`* 控制通配符在路径规则中的默认行为。
58+
如果 `GIT_GLOB_PATHSPECS` 设置为 1, 通配符表现为通配符(这是默认设置); 如果 `GIT_NOGLOB_PATHSPECS` 设置为 1,通配符仅匹配字面。意思是 `*.c` 只会匹配 _文件名是_ ``*.c'' 的文件, 而不是以 `.c` 结尾的文件。
59+
你可以在各个路径规格中用 `:(glob)` `:(literal)` 开头来覆盖这个配置,如 `:(glob)*.c`
6060

61-
*`GIT_LITERAL_PATHSPECS`* disables both of the above behaviors; no wildcard characters will work, and the override prefixes are disabled as well.
61+
*`GIT_LITERAL_PATHSPECS`* 禁用上面的两种行为;通配符将不能用,前缀覆盖也不能用。
6262

63-
*`GIT_ICASE_PATHSPECS`* sets all pathspecs to work in a case-insensitive manner.
63+
*`GIT_ICASE_PATHSPECS`* 让所有的路径规格忽略大小写。
6464

6565

66-
==== Commiting
66+
==== 提交
6767

68-
The final creation of a Git commit object is usually done by `git-commit-tree`, which uses these environment variables as its primary source of information, falling back to configuration values only if these aren't present.
68+
Git 提交对象的创建通常最后是由 `git-commit-tree` 来完成, `git-commit-tree` 用这些环境变量作主要的信息源。 仅当这些值不存在才回退到预置的值。
6969

70-
*`GIT_AUTHOR_NAME`* is the human-readable name in the ``author'' field.
70+
*`GIT_AUTHOR_NAME`* ``author'' 字段的可读的名字。
7171

72-
*`GIT_AUTHOR_EMAIL`* is the email for the ``author'' field.
72+
*`GIT_AUTHOR_EMAIL`* ``author'' 字段的邮件。
7373

74-
*`GIT_AUTHOR_DATE`* is the timestamp used for the ``author'' field.
74+
*`GIT_AUTHOR_DATE`* ``author'' 字段的时间戳。
7575

76-
*`GIT_COMMITTER_NAME`* sets the human name for the ``committer'' field.
76+
*`GIT_COMMITTER_NAME`* ``committer'' 字段的可读的名字。
7777

78-
*`GIT_COMMITTER_EMAIL`* is the email address for the ``committer'' field.
78+
*`GIT_COMMITTER_EMAIL`* ``committer'' 字段的邮件。
7979

80-
*`GIT_COMMITTER_DATE`* is used for the timestamp in the ``committer'' field.
80+
*`GIT_COMMITTER_DATE`* ``committer'' 字段的时间戳。
8181

82-
*`EMAIL`* is the fallback email address in case the `user.email` configuration value isn't set.
83-
If _this_ isn't set, Git falls back to the system user and host names.
82+
如果 `user.email` 没有配置, 就会用到 *`EMAIL`* 指定的邮件地址。
83+
如果 _这个_ 也没有设置, Git 继续回退使用系统用户和主机名。
8484

8585

86-
==== Networking
86+
==== 网络
8787

88-
Git uses the `curl` library to do network operations over HTTP, so *`GIT_CURL_VERBOSE`* tells Git to emit all the messages generated by that library.
89-
This is similar to doing `curl -v` on the command line.
88+
Git 使用 `curl` 库通过 HTTP来完成网络操作, 所以 *`GIT_CURL_VERBOSE`* 告诉 Git 显示所有由那个库产生的消息。
89+
这跟在命令行执行 `curl -v` 差不多。
9090

91-
*`GIT_SSL_NO_VERIFY`* tells Git not to verify SSL certificates.
92-
This can sometimes be necessary if you're using a self-signed certificate to serve Git repositories over HTTPS, or you're in the middle of setting up a Git server but haven't installed a full certificate yet.
91+
*`GIT_SSL_NO_VERIFY`* 告诉 Git 不用验证 SSL 证书。
92+
这在有些时候是需要的, 例如你用一个自己签名的证书通过 HTTPS 来提供 Git 服务, 或者你正在搭建 Git 服务器,还没有安装完全的证书。
9393

9494

95-
If the data rate of an HTTP operation is lower than *`GIT_HTTP_LOW_SPEED_LIMIT`* bytes per second for longer than *`GIT_HTTP_LOW_SPEED_TIME`* seconds, Git will abort that operation.
96-
These values override the `http.lowSpeedLimit` and `http.lowSpeedTime` configuration values.
95+
如果 Git 操作在网速低于 *`GIT_HTTP_LOW_SPEED_LIMIT`* 字节/秒,并且持续 *`GIT_HTTP_LOW_SPEED_TIME`* 秒以上的时间,Git 会终止那个操作。
96+
这些值会覆盖 `http.lowSpeedLimit` `http.lowSpeedTime` 配置的值。
9797

98-
*`GIT_HTTP_USER_AGENT`* sets the user-agent string used by Git when communicating over HTTP.
99-
The default is a value like `git/2.0.0`.
98+
*`GIT_HTTP_USER_AGENT`* 设置 Git 在通过 HTTP 通讯时用到的 user-agent。
99+
默认值类似于 `git/2.0.0`
100100

101101

102-
==== Diffing and Merging
102+
==== 比较和合并
103103

104-
*`GIT_DIFF_OPTS`* is a bit of a misnomer.
105-
The only valid values are `-u<n>` or `--unified=<n>`, which controls the number of context lines shown in a `git diff` command.
104+
*`GIT_DIFF_OPTS`* 这个有点起错名字了
105+
有效值仅支持 `-u<n>` `--unified=<n>`,用来控制在 `git diff` 命令中显示的内容行数。
106106

107-
*`GIT_EXTERNAL_DIFF`* is used as an override for the `diff.external` configuration value.
108-
If it's set, Git will invoke this program when `git diff` is invoked.
107+
*`GIT_EXTERNAL_DIFF`* 用来覆盖 `diff.external` 配置的值。
108+
如果设置了这个值, 当执行Git `git diff` 时,Git 会调用该程序。
109109

110-
*`GIT_DIFF_PATH_COUNTER`* and *`GIT_DIFF_PATH_TOTAL`* are useful from inside the program specified by `GIT_EXTERNAL_DIFF` or `diff.external`.
111-
The former represents which file in a series is being diffed (starting with 1), and the latter is the total number of files in the batch.
110+
*`GIT_DIFF_PATH_COUNTER`* *`GIT_DIFF_PATH_TOTAL`* 对于 `GIT_EXTERNAL_DIFF` `diff.external` 指定的程序有用。
111+
前者表示在一系列文件中哪个是被比较的(从 1 开始),后者表示每批文件的总数。
112112

113-
*`GIT_MERGE_VERBOSITY`* controls the output for the recursive merge strategy.
114-
The allowed values are as follows:
113+
*`GIT_MERGE_VERBOSITY`* 控制递归合并策略的输出。
114+
允许的值有下面这些:
115115

116-
* 0 outputs nothing, except possibly a single error message.
117-
* 1 shows only conflicts.
118-
* 2 also shows file changes.
119-
* 3 shows when files are skipped because they haven't changed.
120-
* 4 shows all paths as they are processed.
121-
* 5 and above show detailed debugging information.
116+
* 0 什么都不输出,除了可能会有一个错误信息。
117+
* 1 只显示冲突。
118+
* 2 还显示文件改变。
119+
* 3 显示因为没有改变被跳过的文件。
120+
* 4 显示处理的所有路径。
121+
* 5 显示详细的调试信息。
122122

123-
The default value is 2.
123+
默认值是 2.
124124

125-
==== Debugging
125+
==== 调试
126126

127-
Want to _really_ know what Git is up to?
128-
Git has a fairly complete set of traces embedded, and all you need to do is turn them on.
129-
The possible values of these variables are as follows:
127+
想 _真正地_ 知道 Git 正在做什么?
128+
Git 内置了相当完整的跟踪信息,你需要做的就是把它们打开。
129+
这些变量的可以用的值如下:
130130

131-
* ``true'', ``1'', or ``2'' – the trace category is written to stderr.
132-
* An absolute path starting with `/` – the trace output will be written to that file.
131+
* ``true'', ``1'', ``2'' – 跟踪类别写到标准错误输出.
132+
* `/` 开头的绝对路径 – 跟踪输出会被写到那个文件。
133133

134-
*`GIT_TRACE`* controls general traces, which don't fit into any specific category.
135-
This includes the expansion of aliases, and delegation to other sub-programs.
134+
*`GIT_TRACE`* 控制常规跟踪,它并不适用于特殊情况。
135+
它跟踪的范围包括别名的展开和其他子程序的委托。
136136

137137
[source,console]
138138
----
@@ -145,8 +145,8 @@ $ GIT_TRACE=true git lga
145145
20:12:49.899675 run-command.c:192 trace: exec: 'less'
146146
----
147147

148-
*`GIT_TRACE_PACK_ACCESS`* controls tracing of packfile access.
149-
The first field is the packfile being accessed, the second is the offset within that file:
148+
*`GIT_TRACE_PACK_ACCESS`* 控制访问打包文件的跟踪信息
149+
第一个字段是被访问的打包文件,第二个是文件的偏移量:
150150

151151
[source,console]
152152
----
@@ -162,7 +162,7 @@ Your branch is up-to-date with 'origin/master'.
162162
nothing to commit, working directory clean
163163
----
164164

165-
*`GIT_TRACE_PACKET`* enables packet-level tracing for network operations.
165+
*`GIT_TRACE_PACKET`* 打开网络操作包级别的跟踪信息
166166

167167
[source,console]
168168
----
@@ -175,8 +175,8 @@ $ GIT_TRACE_PACKET=true git ls-remote origin
175175
# […]
176176
----
177177

178-
*`GIT_TRACE_PERFORMANCE`* controls logging of performance data.
179-
The output shows how long each particular git invocation takes.
178+
*`GIT_TRACE_PERFORMANCE`* 控制性能数据的日志打印。
179+
输出显示了每个 Git 命令调用花费的时间。
180180

181181
[source,console]
182182
----
@@ -198,7 +198,7 @@ Checking connectivity: 170994, done.
198198
20:18:25.233159 trace.c:414 performance: 6.112217000 s: git command: 'git' 'gc'
199199
----
200200

201-
*`GIT_TRACE_SETUP`* shows information about what Git is discovering about the repository and environment it's interacting with.
201+
*`GIT_TRACE_SETUP`* 显示 Git 发现的关于版本库和交互环境的信息
202202

203203
[source,console]
204204
----
@@ -212,26 +212,26 @@ Your branch is up-to-date with 'origin/master'.
212212
nothing to commit, working directory clean
213213
----
214214

215-
==== Miscellaneous
215+
==== 其它
216216

217-
*`GIT_SSH`*, if specified, is a program that is invoked instead of `ssh` when Git tries to connect to an SSH host.
218-
It is invoked like `$GIT_SSH [username@]host [-p <port>] <command>`.
219-
Note that this isn't the easiest way to customize how `ssh` is invoked; it won't support extra command-line parameters, so you'd have to write a wrapper script and set `GIT_SSH` to point to it.
220-
It's probably easier just to use the `~/.ssh/config` file for that.
217+
如果指定了 *`GIT_SSH`*, Git 连接 SSH 主机时会用指定的程序代替 `ssh`
218+
它会被用 `$GIT_SSH [username@]host [-p <port>] <command>` 的命令方式调用。
219+
这不是配置定制 `ssh` 调用方式的最简单的方法; 它不支持额外的命令行参数, 所以你必须写一个封装脚本然后让 `GIT_SSH` 指向它。
220+
可能用 `~/.ssh/config` 会更简单。
221221

222-
*`GIT_ASKPASS`* is an override for the `core.askpass` configuration value.
223-
This is the program invoked whenever Git needs to ask the user for credentials, which can expect a text prompt as a command-line argument, and should return the answer on `stdout`.
224-
(See <<_credential_caching>> for more on this subsystem.)
222+
*`GIT_ASKPASS`* 覆盖了 `core.askpass` 配置。
223+
这是 Git 需要向用户请求验证时用到的程序,它接受一个文本提示作为命令行参数,并在 `stdout` 中返回应答。
224+
(查看 <<_credential_caching>>_ 访问更多相关内容)
225225

226-
*`GIT_NAMESPACE`* controls access to namespaced refs, and is equivalent to the `--namespace` flag.
227-
This is mostly useful on the server side, where you may want to store multiple forks of a single repository in one repository, only keeping the refs separate.
226+
*`GIT_NAMESPACE`* 控制有命令空间的引用的访问,与 `--namespace` 标志是相同的.
227+
这主要在服务器端有用, 如果你想在一个版本库中存储单个版本库的多个 fork, 只要保持引用是隔离的就可以。
228228

229-
*`GIT_FLUSH`* can be used to force Git to use non-buffered I/O when writing incrementally to stdout.
230-
A value of 1 causes Git to flush more often, a value of 0 causes all output to be buffered.
231-
The default value (if this variable is not set) is to choose an appropriate buffering scheme depending on the activity and the output mode.
229+
*`GIT_FLUSH`* 强制 Git 在向标准输出增量写入时使用没有缓存的 I/O
230+
设置为 1 让 Git 刷新更多, 设置为 0 则使所有的输出被缓存。
231+
默认值(若此变量未设置)是根据活动和输出模式的不同选择合适的缓存方案。
232232

233-
*`GIT_REFLOG_ACTION`* lets you specify the descriptive text written to the reflog.
234-
Here's an example:
233+
*`GIT_REFLOG_ACTION`* 让你可以指定描述性的文字写到 reflog 中。
234+
这有个例子:
235235

236236
[source,console]
237237
----

0 commit comments

Comments
 (0)