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

Re: Decompressing a tree to a location other than the working directory

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 6, 2010, 19:58 UTC
Message-ID
<m3mxszo6na.fsf@localhost.localdomain>
In-Reply-To
<AANLkTi=RjcQ_-PNUt781jhYEA-8krqXpdHRenVyR_Rc4@mail.gmail.com>
Joshua Shrader <jshrader83@gmail.com> writes:
Show 6 quoted lines
> git checkout allows one to checkout a particular version of a certain
> path in the working directory.  Are there accessible plumbing commands
> that can be used to accomplish the same thing, but change the target
> directory.  For example, if I wanted to checkout a certain path, but
> wanted to check it out somewhere external to my working directory /
> repository?
Porcelain way: check out first example in git-archive(1) manpage
  EXAMPLES
  ========
  git archive --format=tar --prefix=junk/ HEAD | (cd /var/tmp/ && tar xf -)
       Create a tar archive that contains the contents of the latest commit
       on the current branch, and extract it in the /var/tmp/junk directory.

Plumbing way: after preparing index (it can be separate file than .git/index), use "git checkout-index" as desceived in second example on manpage:

  EXAMPLES
  ========
  Using `git checkout-index` to "export an entire tree"
        The  prefix  ability  basically  makes  it trivial to use git check-
        out-index as an "export as tree" function.  Just  read  the  desired
        tree into the index, and do:
          $ git checkout-index --prefix=git-export-dir/ -a
        `git checkout-index` will "export" the index into the specified direc-
        tory.
        The final "/" is important. The exported name is literally just pre-
        fixed  with  the  specified string
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Michael Witten
Message 4 of 4 in “Decompressing a tree to a location other than the working directory”
  1. Joshua ShraderAug 6, 2010
  2. Jonathan NiederAug 6, 2010
  3. Michael WittenAug 7, 2010
  4. Jakub NarebskiAug 6, 2010

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.