# No working tree repository

8 messages from 2010-06-15 to 2010-06-16. Participants: Phillip Susi, Matthieu Moy, Andreas Schwab, Wesley J. Landaker, Johannes Sixt, Peter Krefting.
Thread: https://gitlist.dev/t/24122

## Phillip Susi, 2010-06-15 17:56

Subject: No working tree repository
Message-ID: <4C17BEB7.90403@cfl.rr.com>
URL: https://gitlist.dev/e/4C17BEB7.90403%40cfl.rr.com

```
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?

```

## Matthieu Moy, 2010-06-15 18:10

Subject: Re: No working tree repository
Message-ID: <vpqy6egi2va.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpqy6egi2va.fsf%40bauges.imag.fr
In-Reply-To: <4C17BEB7.90403@cfl.rr.com>

```
Phillip Susi <psusi@cfl.rr.com> writes:

> 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.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Phillip Susi, 2010-06-15 18:33

Subject: Re: No working tree repository
Message-ID: <4C17C77C.9000002@cfl.rr.com>
URL: https://gitlist.dev/e/4C17C77C.9000002%40cfl.rr.com
In-Reply-To: <vpqy6egi2va.fsf@bauges.imag.fr>

```
On 6/15/2010 2:10 PM, Matthieu Moy wrote:
> 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.

```

## Andreas Schwab, 2010-06-15 19:39

Subject: Re: No working tree repository
Message-ID: <m2ocfcw0f1.fsf@igel.home>
URL: https://gitlist.dev/e/m2ocfcw0f1.fsf%40igel.home
In-Reply-To: <vpqy6egi2va.fsf@bauges.imag.fr>

```
Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:

> 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.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

```

## Wesley J. Landaker, 2010-06-15 20:41

Subject: Re: No working tree repository
Message-ID: <201006151441.35554.wjl@icecavern.net>
URL: https://gitlist.dev/e/201006151441.35554.wjl%40icecavern.net
In-Reply-To: <4C17C77C.9000002@cfl.rr.com>

```
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.

```

## Matthieu Moy, 2010-06-15 20:58

Subject: Re: No working tree repository
Message-ID: <vpq7hm0dndf.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpq7hm0dndf.fsf%40bauges.imag.fr
In-Reply-To: <4C17C77C.9000002@cfl.rr.com>

```
Phillip Susi <psusi@cfl.rr.com> writes:

> On 6/15/2010 2:10 PM, Matthieu Moy wrote:
>> 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.

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.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Johannes Sixt, 2010-06-16 06:20

Subject: Re: No working tree repository
Message-ID: <4C186D45.7030203@viscovery.net>
URL: https://gitlist.dev/e/4C186D45.7030203%40viscovery.net
In-Reply-To: <4C17C77C.9000002@cfl.rr.com>

```
Am 6/15/2010 20:33, schrieb Phillip Susi:
> but I can't figure out how to empty the index.

git rm -r .

-- Hannes

```

## Peter Krefting, 2010-06-16 08:36

Subject: Re: No working tree repository
Message-ID: <alpine.DEB.2.00.1006160933270.10800@ds9.cixit.se>
URL: https://gitlist.dev/e/alpine.DEB.2.00.1006160933270.10800%40ds9.cixit.se
In-Reply-To: <4C17C77C.9000002@cfl.rr.com>

```
Phillip Susi:

> 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.

-- 
\\// Peter - http://www.softwolves.pp.se/

```
