tags:

views:

49

answers:

4

I have gitosis running on my server. My build system needs to get a copy of the code from gitosis. Right now I clone the whole repository, which takes a long time.

How do I get just the head of a branch? (I've tried git archive, but can't seem to get an archive from gitosis.)

Can I create an archive from a bare repository?

+2  A: 

Pass the --depth=1 flag to git clone to only get the HEAD commit. This creates a "shallow clone". Note that there are limitations with a shallow clone: you can't get the full history (obviously), you cannot clone or pull from it, and you cannot push from it.

mipadi
A: 

I just created a test bare repo and yes, you can create an archive from a bare repository.

$ cd /tmp/foo.git/
$ git archive --output=/tmp/foo.tgz HEAD
bstpierre
A: 

Depending on whether remote side enabled archive support, you can try:

git archive --remote=git://git.example.com/repo.git --output=repo.zip HEAD

But you have to be either able to access repository via SSH protocol, or support for this has to be explicitely enabled in git daemon, so it is rare.

Jakub Narębski
How do I enable archive support on the remote side. And why is it rarely enabled, is there some danger with it?
ablerman
For access via `git://` protocol, the command line that invokes `git daemon` (in inetd, xindetd, etc.) must contain `--enable=upload-archive`; you can also try to just setup `daemon.uploadarch` to true in **remote repository**
Jakub Narębski
Does gitosis support git://?
ablerman
@ablerman: I don't know if gitosis support `git://` (I think it can configure `git daemon`), but if you have SSH access or repository is on the same filesystem you don't need to enable anything (just checked).
Jakub Narębski
+1  A: 

gitosis does not yet support git-archive, AFAIS. The corresponding branch at http://eagain.net/gitweb/?p=gitosis.git;a=commitdiff;h=refs/heads/remote-archive has not been merged.

So you can't use "git archive --remote=git://git.example.com/repo.git ..." with gitosis yet.

thh