# Easy way to empty working tree?

3 messages from 2006-07-21 to 2006-07-21. Participants: Robin Luckey, Linus Torvalds, Alex Riesen.
Thread: https://gitlist.dev/t/4934

## Robin Luckey, 2006-07-21 01:28

Subject: Easy way to empty working tree?
Message-ID: <761519800607201828m19684b2jc267411ef3b8b9e2@mail.gmail.com>
URL: https://gitlist.dev/e/761519800607201828m19684b2jc267411ef3b8b9e2%40mail.gmail.com

```
I have some very large git repositories that serve mainly as archives,
and it would be nice to clear out the working directories for the
repositories I am not currently working with. I'm not trying to delete
the files from the repository, I just want free up space in idle
repositories.

After mothballing the repository with git-repack -a -d and git clean
-d -x, is there a convenient one-liner to empty the files out the
working directory?

Thanks,
Robin

```

## Linus Torvalds, 2006-07-21 02:48

Subject: Re: Easy way to empty working tree?
Message-ID: <Pine.LNX.4.64.0607201944460.29649@g5.osdl.org>
URL: https://gitlist.dev/e/Pine.LNX.4.64.0607201944460.29649%40g5.osdl.org
In-Reply-To: <761519800607201828m19684b2jc267411ef3b8b9e2@mail.gmail.com>

```


On Thu, 20 Jul 2006, Robin Luckey wrote:
>
> I have some very large git repositories that serve mainly as archives,
> and it would be nice to clear out the working directories for the
> repositories I am not currently working with. I'm not trying to delete
> the files from the repository, I just want free up space in idle
> repositories.

Well, that actually sounds like you might want to just make them totally 
"bare" repositories, ie you can just do something like

	mv repo/.git repo.git
	rm -rf repo

and then "repo.git" is a valid bare repository.

However, if you actually want to just clear the checked-out files:

> After mothballing the repository with git-repack -a -d and git clean
> -d -x, is there a convenient one-liner to empty the files out the
> working directory?

Well, you can do

	git ls-files -z | xargs -0 rm -f --

or something, or indeed just do a "rm -rf *", since the only thing you 
actually would want to save is the ".git" directory.

		Linus

```

## Alex Riesen, 2006-07-21 07:08

Subject: Re: Easy way to empty working tree?
Message-ID: <81b0412b0607210008l45198948sab391a8cf94c7af8@mail.gmail.com>
URL: https://gitlist.dev/e/81b0412b0607210008l45198948sab391a8cf94c7af8%40mail.gmail.com
In-Reply-To: <Pine.LNX.4.64.0607201944460.29649@g5.osdl.org>

```
On 7/21/06, Linus Torvalds <torvalds@osdl.org> wrote:
> > After mothballing the repository with git-repack -a -d and git clean
> > -d -x, is there a convenient one-liner to empty the files out the
> > working directory?
>
> Well, you can do
>
>         git ls-files -z | xargs -0 rm -f --
>

That'd be not enough for kernel after it was compiled.
Maybe this:

   find . -maxdepth 1 -not -name .git -not -name . -print0 | xargs -0 rm -rf --

```
