On 11/07/2015 07:18 PM, lee wrote: > Hi, > > does anyone know how to put a copy of a local repo onto a web server > (apache) so that the repo can be pulled via http?
If this is a one-off job, you can just scp your full local copy (for example, repo.git) to a public location accessible via the web. Then you should be able to `git clone http://example.com/path/to/repo.git` and obtain whatever was in the repo you just uploaded. The ".git" extension is important if that's what the repo directory is named -- cloning over HTTP and SSH work differently! If you'd like to set up a more permanent public location for collaboration, there's a few more steps. > The instructions I'm finding suggest to init a bare repo So far so good, but things get a little weird here. First, create the bare repo on your server. $ git init --bare Now a critical step, enable the post-update hook: $ cd hooks/ $ mv post-update.sample post-update At this point the repo is ready on the server, but it doesn't contain anything. You have to push the contents of your local repository to the bare one on the server. You'll need SSH access to the web server; run this from within the git repo on your local machine: $ git push --all [email protected]:/path/to/repo.git If all goes well, you should see some statistics from the push operation and it will complete successfully. The data from your local repo will have been copied to the server, and that post-update hook will take care of "checking out" the files on the server. Now you can clone the server's bare repo over HTTP: $ git clone http://example.com/path/to/repo.git (the ".git" suffix is again, necessary). If you're going to be making changes locally and want to push them to the server occasionally, look into git add-remote. Or if you're setting up the "authoritative" git repo for a project, stick "--set-upstream" on that push command above.

