Much like this SO post, I have the following workflow that i would like to maintain with git:
- Multiple people develop locally
- Commit a few things
- Commit more things
- Push to Staging
- Test new code on Staging
- Push to Production
Our staging server serves many different sites. I would like to set up the repository for each in a different folder in a user's home directory. Each repository will have a post-receive hook (ala the Daniel Messier article) that checks out the changes into the web root for that site/repository.
It's number six that is giving me trouble.
When I try to run any git commands, I get the error "fatal: This operation must be run in a work tree". I get this error whether I am running 'git status' from the repository (/home/gituser/website1.git - which I don't believe should work anyway..) or from the web root (/var/www/website1).
However, if I specify the GIT_DIR and GIT_WORK_TREE, then I am able to run git commands. Both of these work:
$ git --git-dir /home/gituser/website1.git --work-tree /var/www/website1 status
$ GIT_DIR=/home/gituser/website1.git GIT_WORK_TREE=/var/www/website1 git status
So I need:
- An alternative to typing the directory and work tree along with every command
- An alternative to setting them as persistent environment variables, because that would only work for website1, not website2, website3, etc
Am I going about this correctly? How can I get git the directory info it needs for each repository?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…