How to use self-hosted git server as production server?
I’m developing a website, and using my own laptop as development server, while using my online server as the production server. And I’m using git to manage my project.
I’ve used heroku before, and I think publishing my website simply using
git push heroku master is really cool, so I plan to build one my self.
So, here’s what I’ve done, I’ve setup git on my production server (with gitosis to manage the access), and on my git repo, I’ve used
git remote add git@production:myrepo.git to add the remote for git repo.
The question is how to grab the code on production server? The production server serves as a git server, so I can only get .git folder rather than the real code. I’ve thought of a trick, that is use
git clone --local myrepo.git myrepo to clone the data on the production server, and in the hooks/ folder of myrepo.git, I edited the
post-receive file as following:
#!/bin/sh touch /tmp/do-we-got-here cd /path/to/clone/myrepo /usr/bin/git pull
After I use
git push production master, the
do-we-got-here file got created, so I can tell the post-receive hook is working, but the
git pull part does not work, when I get to the myrepo folder, and use
git pull, it’s still pulling from myrepo.git.
So I’m wondering how to handler this? I know this is possible because hosting sites like heroku are working! But the questione is how?
One Solution collect form web for “How to use self-hosted git server as production server?”
I had a similar problem, this is what helped me.
#!/bin/sh touch /tmp/do-we-got-here cd /path/to/clone/myrepo unset GIT_DIR git pull
When running git hook, GIT_DIR is set. That means your pull won’t run with the second repository in the directory you changed to.