git/list[1] front-page[2] threads[3] people[4] search[5] about
 

easy repository initialization that turned out not to be that easy

From
Steffen Prohaska <prohaska@zib.de>
Date
Jul 25, 2007, 20:05 UTC
Message-ID
<0EAD32C5-11DA-4B99-919D-87C0006A389C@zib.de>

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
Next: Johannes Schindelin
Message 1 of 2 in “easy repository initialization that turned out not to be that easy”
  1. Steffen ProhaskaJul 25, 2007
  2. Johannes SchindelinJul 25, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.