threads / discuss / 9223

easy repository initialization that turned out not to be that easy

Subject: easy repository initialization that turned out not to be that easy

## tl;dr

2 messages between Jul 25, 2007 and Jul 25, 2007.

replies: 1people: 2as markdown or json

Steffen Prohaska· Jul 25, 2007, 20:05 UTC · lore

I stumbled about some tasks that I expected to be easy but turned out not to be that easy ...

(with git version 1.5.3.rc2.29.gc4640f)
1) How can I switch a private repository to shared as if it
was created by 'git-init --shared' in the first place?

Just executing 'git-init --shared' in the repo doesn't adjust permissions as needed.

Cloning it to shared doesn't work either because the meaning of 'git-clone --bare --shared' is different from 'git-init --shared'.

So I created a fresh repository
    mkdir shared.git
    cd shared.git
    git --bare init --shared
and tried to naively fetch all by executing
    git fetch ../private.git

Hmm... it does a lot of things, but I ended without branches. fetch apparently has nothing like '--all'.

... but push has, so I finally did
    cd ../private.git
    git push --all ../shared.git
    git push --tags ../shared.git

Note, 'git push --all --tags' refused to work, so I needed to push branches and tags separately.

Is it really that hard, or did I miss something?
2) How can I set up an empty bare repository that shares
objects with an existing repository? I'd like to do that
to save space and bandwidth.

I started to search for something like 'git init --reference' or 'git init -l', similar to what 'git clone' provides.

I don't remember all approaches I tried, but finally I used
    git clone --bare -l existing.git new.git
    cd new.git
    mv refs/head/master .
    rm -rf refs/heads/* refs/tags/*
    mv master refs/heads

I remember that I needed to leave the master in place because otherwise a 'git push' didn't recognize that objects are already present and transferred everything, which is quite annoying over a slower network connection. With master in place the first push to new.git worked as expected. Only the additional objects were sent.

Did I miss something?
	Steffen
Johannes Schindelin· Jul 25, 2007, 20:15 UTC · re: Steffen Prohaska · lore

Re: easy repository initialization that turned out not to be that easy

Hi,
On Wed, 25 Jul 2007, Steffen Prohaska wrote:
> Cloning it to shared doesn't work either because the meaning of 
> 'git-clone --bare --shared' is different from 'git-init --shared'.

Yes, I lamented on that already. But we cannot change that. Too many users.

Show 7 quoted lines
>    mkdir shared.git
>    cd shared.git
>    git --bare init --shared
> 
> and tried to naively fetch all by executing
> 
>    git fetch ../private.git

Almost. "git fetch" does not store anything by default, so you have to do something like

	$ git config remote.origin.url ../private.git
	$ git config remote.origin.fetch 'refs/*:refs/*'
	$ git fetch
Eventually, I would like that to be available with
	$ git remote add --mirror fetch ../private.git
If nobody beats me to it, I'll do it later today.

Ciao, Dscho

← back to recent threads