1 |
On 11/07/2015 07:18 PM, lee wrote: |
2 |
> Hi, |
3 |
> |
4 |
> does anyone know how to put a copy of a local repo onto a web server |
5 |
> (apache) so that the repo can be pulled via http? |
6 |
|
7 |
If this is a one-off job, you can just scp your full local copy (for |
8 |
example, repo.git) to a public location accessible via the web. Then you |
9 |
should be able to `git clone http://example.com/path/to/repo.git` and |
10 |
obtain whatever was in the repo you just uploaded. |
11 |
|
12 |
The ".git" extension is important if that's what the repo directory is |
13 |
named -- cloning over HTTP and SSH work differently! |
14 |
|
15 |
If you'd like to set up a more permanent public location for |
16 |
collaboration, there's a few more steps. |
17 |
|
18 |
|
19 |
> The instructions I'm finding suggest to init a bare repo |
20 |
|
21 |
So far so good, but things get a little weird here. First, create the |
22 |
bare repo on your server. |
23 |
|
24 |
$ git init --bare |
25 |
|
26 |
Now a critical step, enable the post-update hook: |
27 |
|
28 |
$ cd hooks/ |
29 |
$ mv post-update.sample post-update |
30 |
|
31 |
At this point the repo is ready on the server, but it doesn't contain |
32 |
anything. You have to push the contents of your local repository to the |
33 |
bare one on the server. You'll need SSH access to the web server; run |
34 |
this from within the git repo on your local machine: |
35 |
|
36 |
$ git push --all user@×××××××.com:/path/to/repo.git |
37 |
|
38 |
If all goes well, you should see some statistics from the push operation |
39 |
and it will complete successfully. The data from your local repo will |
40 |
have been copied to the server, and that post-update hook will take care |
41 |
of "checking out" the files on the server. |
42 |
|
43 |
Now you can clone the server's bare repo over HTTP: |
44 |
|
45 |
$ git clone http://example.com/path/to/repo.git |
46 |
|
47 |
(the ".git" suffix is again, necessary). |
48 |
|
49 |
If you're going to be making changes locally and want to push them to |
50 |
the server occasionally, look into git add-remote. Or if you're setting |
51 |
up the "authoritative" git repo for a project, stick "--set-upstream" on |
52 |
that push command above. |