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.

  • git conflict: diff between BASE version and OTHER version
  • Are there any reasons to not use SSH as a Git transport?
  • Is git-svn dcommit after merging in git dangerous?
  • How to list all tags that contain a commit?
  • Remove unused assets from git history
  • Git with Ldap on Ubuntu with Apache
  • 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:

    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?

  • How can I push a new branch?
  • Best way to merge a git revision into a mercurial repository?
  • git-svn dcommiting a single git commit
  • Add back a removed file and don't track it
  • Is it possible to get a list of merges into a branch from the Github website OR API?
  • git push --force, behind the scenes
  • 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.

    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.

    Git Baby is a git and github fan, let's start git clone.