Skip to contentSkip to conversation

No working tree repository

DISCUSSION Phillip Susi 6 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I'd like to keep a local copy of the kernel repository mainly for searching the history. The working tree uses up nearly 400mb of disk space that I do not normally need. How can I remove the working tree, and keep only the packed repository so I can review the logs, and only check out a working copy if I actually want to edit or compile the sources?

#1 lore raw
Quoted 6 lines · Phillip Susi

I'd like to keep a local copy of the kernel repository mainly for searching the history. The working tree uses up nearly 400mb of disk space that I do not normally need. How can I remove the working tree, and keep only the packed repository so I can review the logs, and only check out a working copy if I actually want to edit or compile the sources?

This is called a "bare" repository. Now, you have the keyword to RTFM ;-).

You can do something like

mv linux-repo linux-tree
cd linux-tree
mv .git ../linux-repo
cd ../linux-repo
git config core.bare true

(and optionnaly remove linux-tree/)

or you could have used "git clone --bare" when you cloned the repository.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#2 lore raw
Quoted 2 lines · Matthieu Moy

This is called a "bare" repository. Now, you have the keyword to RTFM ;-).

Ahh, that's the magic word I was groping for.

It seems that --bare on clone will prevent the checkout of the local working tree. If I decide I do want the sources today I can just check them out, but what is the proper way to do the reverse? I was thinking something like somehow empty the index file then do a git-reset or git-checkout-index to clean up the working tree to match the empty index, but I can't figure out how to empty the index.

#3 lore raw
Quoted 8 lines · On Tuesday, June 15, 2010 12:33:32 Phillip Susi wrote:

Ahh, that's the magic word I was groping for.

It seems that --bare on clone will prevent the checkout of the local working tree. If I decide I do want the sources today I can just check them out, but what is the proper way to do the reverse? I was thinking something like somehow empty the index file then do a git-reset or git-checkout-index to clean up the working tree to match the empty index, but I can't figure out how to empty the index.

I often want to have a regular tree, but only sometimes check it out, and I want it to be in-place (e.g. not a bare repository and a separate work- tree).

What I do is I make a local "empty" branch with no files or ancestory. For this I have a "git-emptybranch" script (attached), but you can easily do this by hand.

Then when I want files, I do:

$ git checkout master  ## or whatever branch

When I'm done, I do

$ git checkout empty

and all the files go away.

Even with empty checked out, I can fetch, push, run gitk --all, etc.

This works well for me.

#5 lore raw
In reply to Phillip Susi

Phillip Susi:

Quoted 1 line

It seems that --bare on clone will prevent the checkout of the local working tree. If I decide I do want the sources today I can just check them out, but what is the proper way to do the reverse?

Then I would recommend creating another clone. I usually do a

  git clone --reference path/to/bare server:path/to/origin newcheckout

to create clones with working trees, without having to pay the penalty of having (yet) another copy of the objects under .git (and with .git in the order of 400 megabytes, and several working copies, it does pay off).

Maintaining this is a lot easier than constantly adding and removing a working tree from the repository.

If you only need a single file, "git show commit:path" should work, even on a bare repository.

Signature · 1 line
\\// Peter - http://www.softwolves.pp.se/
#6 lore raw
In reply to Phillip Susi
Quoted 4 lines · Phillip Susi
Quoted 2 lines · Matthieu Moy

This is called a "bare" repository. Now, you have the keyword to RTFM ;-).

Quoted 8 lines

Ahh, that's the magic word I was groping for.

It seems that --bare on clone will prevent the checkout of the local working tree. If I decide I do want the sources today I can just check them out, but what is the proper way to do the reverse? I was thinking something like somehow empty the index file then do a git-reset or git-checkout-index to clean up the working tree to match the empty index, but I can't figure out how to empty the index.

rm -fr * # use at your own risk
rm -f .git/index

Then, you can get back a tree with "git checkout" or "git checkout HEAD -- .". The advantage of this solution over the empty-branch solution is that although you destroyed your index, HEAD is still there so "git log" and friends will show you where you are.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/
#7 lore raw
In reply to Matthieu Moy
Quoted 7 lines · Matthieu Moy

You can do something like

mv linux-repo linux-tree
cd linux-tree
mv .git ../linux-repo
cd ../linux-repo
git config core.bare true

Or shorter:

$ git clone --bare linux-repo

(which creates linux-repo.git and uses hardlinks, so it won't waste space)

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."