One requirement is for local git to automatically perform git pull under/dir/foo on a remote server after the push to a remote git repo. It's a very simple requirement to add a post-receive hook to the hook in the remote Foo.git warehouse and add a git pull to the hooks. But the actual operation of the time to find a problem, because this ignores a small detail of the problem.
Before you do so, the code in your head is as follows:
#!/bin/sh
Cd/var/git/web3/etc/puppet
/usr/bin/git Pull
With this code, after git push ssh://git@ownlinux.org:/opt/foo.git, it is found that the/dir/foo directory on the remote server does not successfully pull to the most recent data, and there are also errors on the terminal (remote:fatal: Not a git repository: '. ' )。 Later, the git hooks are found to invoke GIT_DIR this environment variable instead of PWD this. So when git pull, it prompts not a git repository: '. ', where "." is git_dir the value of this environment variable.
After the code for the hook is changed to the following, it works:
#!/bin/sh
Unset $ (git rev-parse--local-env-vars)
Cd/var/git/web3/etc/puppet
/usr/bin/git Pull
Friends who use Git to version control hope you don't ignore this little detail as much as I do.