When initialize a new git repository (on Linux/Ubuntu), we use:
# 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
The first line “GIT_DIR=…” confuses me, it seems bash will get a env variable and git use the first to init the new project, BUT how? Who can explain this little magic?
This is a feature of Bash and other Bourne-compatible shells:
runs
cmdwithVARset tovaland otherwise the environment of the shell itself.Try running the following commands: