threads / discuss / 27040

New to git

Subject: New to git

## tl;dr

6 messages between Apr 8, 2011 and Apr 9, 2011.

replies: 5people: 5as markdown or json

Marco Maggesi· Apr 8, 2011, 19:43 UTC · lore

Hi, I'm considering to use git to track my sources. So far I was able to use git on a single machine and play with its basic features.

Now I would like to setup a repository on a server and use it as a central point of distribution for a few other computers. As far as I can understand, the default mechanism for push / pull requires that git is installed on every machine, including the server.

My problem is that I can hardly install git on the server for several reasons that I will not explain here (also I'm not the administrator of the server). So I am looking for other solutions.

For the moment I came only to the following idea: mount the remote repository via fuse-ssh and use the local installation of git to push / pull changes. Surely it is inefficient but I don't care too much (my repositories are small enough I think). Can you see other drawbacks of this solution?

Also I wonder if other kind of synchronizations are possible (rsync, unison, ...).

Are there other obvious solutions that I'm missing?

Thanks, Marco

Jeff King· Apr 8, 2011, 20:10 UTC · re: Marco Maggesi · lore

Re: New to git

On Fri, Apr 08, 2011 at 09:43:09PM +0200, Marco Maggesi wrote:
> Now I would like to setup a repository on a server and use it as a
> central point of distribution for a few other computers.
> As far as I can understand, the default mechanism for push / pull
> requires that git is installed on every machine, including the server.

Yes, it's the default, but there are other mechanisms that don't require server support. For example, rsync, and dumb http and ftp support. They're not as efficient, but they do work.

For pushing, they are not as convenient. The dumb http push support goes over DAV, so you must have a DAV server set up. Similarly, the rsync support does not (as far as I know) do rsync-over-ssh, but expects to connect to the rsync daemon directly.

But if you are just using the server as a distribution point for a single repository, it can be much simpler. For example, if you always just want to push and overwrite what is on the server (i.e., like a mirror), you can just use plain rsync outside of git. To avoid mirror lag, you do want to update the objects before the refs. So this:

  LOCAL=/path/to/repo.git
  REMOTE=server:path/to/repo.git
  rsync -a $LOCAL/objects/ $REMOTE/objects/
  rsync -a $LOCAL $REMOTE

would work. And then expose repo.git on the server via http or ftp, and clients can clone directly from it.

> My problem is that I can hardly install git on the server for several
> reasons that I will not explain here (also I'm not the administrator
> of the server).

You didn't list your reasons, so I'll assume they're good. But note that you don't need to be the administrator to accept a git push. You can build it as a regular user, and have git connect over ssh and run the server side.

Show 6 quoted lines
> For the moment I came only to the following idea: mount the remote
> repository via fuse-ssh and use the local installation of git to push
> / pull changes.
> Surely it is inefficient but I don't care too much (my repositories
> are small enough I think).
> Can you see other drawbacks of this solution?

That is inefficient, but I think it would work OK. If you are doing that, though, you are probably better off just rsyncing the whole result as I showed above. It's less inefficient and easier to set up (if you have rsync on the server, of course).

-Peff
Marco Maggesi· Apr 9, 2011, 19:15 UTC · re: Jeff King · lore

Re: New to git

Hi Chris and Peff,
2011/4/8 Jeff King <peff@peff.net>:
Show 13 quoted lines
> But if you are just using the server as a distribution point for a
> single repository, it can be much simpler. For example, if you always
> just want to push and overwrite what is on the server (i.e., like a
> mirror), you can just use plain rsync outside of git. To avoid mirror
> lag, you do want to update the objects before the refs. So this:
>
>  LOCAL=/path/to/repo.git
>  REMOTE=server:path/to/repo.git
>  rsync -a $LOCAL/objects/ $REMOTE/objects/
>  rsync -a $LOCAL $REMOTE
>
> would work. And then expose repo.git on the server via http or ftp, and
> clients can clone directly from it.
this is the solution I was looking for (but I where not sure that it worked).
> You didn't list your reasons, so I'll assume they're good. But note that
> you don't need to be the administrator to accept a git push. You can
> build it as a regular user, and have git connect over ssh and run the
> server side.

Well, the server is a very old machine and I didn't find easy to compile git on it because of many missing dependencies (but I didn't try very hard either). A better solution would be to upgrade the server. But your solution is perfect meanwhile.

Thank you, Marco

Dmitry Potapov· Apr 9, 2011, 19:35 UTC · re: Marco Maggesi · lore

Re: New to git

On Sat, Apr 9, 2011 at 11:15 PM, Marco Maggesi <marco.maggesi@gmail.com> wrote:
>
> Well, the server is a very old machine and I didn't find easy to
> compile git on it because of many missing dependencies (but I didn't
> try very hard either).

Some time ago, I built git on an old machine running Linux (RedHat 8.0 but maybe some packages were upgraded). Here is the line that I used:

make NO_OPENSSL=1 NO_NSEC=1 NO_CURL=1 NO_TCLTK=1 NO_PYTHON=1

I needed git only to push and fetch to that repository, and it worked well for me.

Dmitry
Matthieu Moy· Apr 9, 2011, 22:41 UTC · re: Marco Maggesi · lore

Re: New to git

Marco Maggesi <marco.maggesi@gmail.com> writes:
Show 19 quoted lines
> Hi Chris and Peff,
>
> 2011/4/8 Jeff King <peff@peff.net>:
>> But if you are just using the server as a distribution point for a
>> single repository, it can be much simpler. For example, if you always
>> just want to push and overwrite what is on the server (i.e., like a
>> mirror), you can just use plain rsync outside of git. To avoid mirror
>> lag, you do want to update the objects before the refs. So this:
>>
>>  LOCAL=/path/to/repo.git
>>  REMOTE=server:path/to/repo.git
>>  rsync -a $LOCAL/objects/ $REMOTE/objects/
>>  rsync -a $LOCAL $REMOTE
>>
>> would work. And then expose repo.git on the server via http or ftp, and
>> clients can clone directly from it.
>
> this is the solution I was looking for (but I where not sure that it
> worked).

It works, but "git push" does something that rsync can't: it will refuse non-fast forward, i.e. refuse to override commits that you don't have locally.

So, I'll just insist on the "if you are just using the server as a distribution point" part. If you ever push from two different machines to the server with rsync, you'll take the risk of loosing data.

If the server runs an HTTP server, an alternative is to push over WebDAV, it doesn't require Git on the server. It's slow, but safer than rsync.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Jonathan Nieder· Apr 8, 2011, 22:54 UTC · re: Marco Maggesi · lore

Pushing to a "dumb" server (Re: New to git)

Hi,
Marco Maggesi wrote:
> My problem is that I can hardly install git on the server for several
> reasons that I will not explain here (also I'm not the administrator
> of the server).
> So I am looking for other solutions.
Have you looked into "git bundle"?

I should also mention that git can be run from ~/bin without trouble. If you lack the ability to modify your $PATH, "git fetch" and "git push" have --upload-pack and --receive-pack options that can be used to specify alternate commands like '~/bin/git upload-pack'.

Ciao, Jonathan

← back to recent threads