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

Re: Easy way to empty working tree?

From
Linus Torvalds <torvalds@osdl.org>
Date
Jul 21, 2006, 02:48 UTC
Message-ID
<Pine.LNX.4.64.0607201944460.29649@g5.osdl.org>
In-Reply-To
<761519800607201828m19684b2jc267411ef3b8b9e2@mail.gmail.com>
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
Previous: Robin LuckeyNext: Alex Riesen
Message 2 of 3 in “Easy way to empty working tree?”
  1. Robin LuckeyJul 21, 2006
  2. Linus TorvaldsJul 21, 2006
  3. Alex RiesenJul 21, 2006

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.