Git Post Receive Hook: update current working branch to staging server

耗尽温柔 提交于 2019-12-04 18:09:19
VonC
cd ../staging/bikereport
git fetch

Beware: your git directory is not your staging/bikereport repo.
It is still the one where the hook is running.

You need to set GIT_DIR to /full/path/ofstaging/bikereport/.git (and to be sure, set GIT_WORK_TREE to /full/path/ofstaging/bikereport) in order for commands run from that repo to work.
And you need to unset GIT_INDEX_FILE!

See "Why doesn't setting GIT_WORK_TREE work in a post-commit hook?" for more details.

You hook should start with:

#!/bin/sh
 unset GIT_INDEX_FILE
 export GIT_WORK_TREE=/full/path/ofstaging/bikereport/
 export GIT_DIR=/full/path/ofstaging/bikereport/.git/
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!