threads / discuss / 4934

Easy way to empty working tree?

Subject: Easy way to empty working tree?

## tl;dr

3 messages between Jul 21, 2006 and Jul 21, 2006.

replies: 2people: 3as markdown or json

Robin Luckey· Jul 21, 2006, 01:28 UTC · lore

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· Jul 21, 2006, 02:48 UTC · re: Robin Luckey · lore

Re: Easy way to empty working tree?

On Thu, 20 Jul 2006, Robin Luckey wrote:
Show 6 quoted lines
>
> 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· Jul 21, 2006, 07:08 UTC · re: Linus Torvalds · lore

Re: Easy way to empty working tree?

On 7/21/06, Linus Torvalds <torvalds@osdl.org> wrote:
Show 8 quoted lines
> > 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 --

← back to recent threads