【发布时间】:2012-03-25 05:15:09
【问题描述】:
当初始化一个新的 git 仓库时(在 Linux/Ubuntu 上),我们使用:
# What this doing:
GIT_DIR=myproject.git git init
#The above line will output: Initialized empty Git Repo...
cd myproject.git
git --bare update-server-info
cp hooks/post-update.sample hooks/post-update
第一行“GIT_DIR=...”让我很困惑,似乎 bash 会得到一个 env 变量,而 git 使用第一个来初始化新项目,但是如何?谁能解释一下这个小魔法?
【问题讨论】:
-
“如何”是什么意思? shell 语法指定在命令的环境中设置分配。 shell 解析命令行,当它看到分配时,它会在启动命令之前在环境中进行分配。
标签: git bash shell environment-variables