git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Decompressing a tree to a location other than the working directory
@ 2010-08-06 18:43 Joshua Shrader
  2010-08-06 18:43 ` Jonathan Nieder
  2010-08-06 19:58 ` Jakub Narebski
  0 siblings, 2 replies; 4+ messages in thread
From: Joshua Shrader @ 2010-08-06 18:43 UTC (permalink / raw)
  To: Git Mailing List; +Cc: Joshua Shrader

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?

Thanks,

Josh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Decompressing a tree to a location other than the working directory
  2010-08-06 18:43 Decompressing a tree to a location other than the working directory Joshua Shrader
@ 2010-08-06 18:43 ` Jonathan Nieder
  2010-08-07  3:10   ` Michael Witten
  2010-08-06 19:58 ` Jakub Narebski
  1 sibling, 1 reply; 4+ messages in thread
From: Jonathan Nieder @ 2010-08-06 18:43 UTC (permalink / raw)
  To: Joshua Shrader; +Cc: Git Mailing List

Joshua Shrader wrote:

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

I don’t know if it is plumbing, but "git archive" is very useful for
that.

 $ git archive HEAD^:Documentation | (cd elsewhere && tar xf -)

Hope that helps,
Jonathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Decompressing a tree to a location other than the working directory
  2010-08-06 18:43 Decompressing a tree to a location other than the working directory Joshua Shrader
  2010-08-06 18:43 ` Jonathan Nieder
@ 2010-08-06 19:58 ` Jakub Narebski
  1 sibling, 0 replies; 4+ messages in thread
From: Jakub Narebski @ 2010-08-06 19:58 UTC (permalink / raw)
  To: Joshua Shrader; +Cc: Git Mailing List

Joshua Shrader <jshrader83@gmail.com> writes:

> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Decompressing a tree to a location other than the working  directory
  2010-08-06 18:43 ` Jonathan Nieder
@ 2010-08-07  3:10   ` Michael Witten
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Witten @ 2010-08-07  3:10 UTC (permalink / raw)
  To: Jonathan Nieder; +Cc: Joshua Shrader, Git Mailing List

On Fri, Aug 6, 2010 at 13:43, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> 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.
>
> I don’t know if it is plumbing, but "git archive" is very useful for
> that.
>
>  $ git archive HEAD^:Documentation | (cd elsewhere && tar xf -)

For single files (rather than directories), you could do this:

  git show HEAD^:path/to/file > /some/path/file

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-07  3:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06 18:43 Decompressing a tree to a location other than the working directory Joshua Shrader
2010-08-06 18:43 ` Jonathan Nieder
2010-08-07  3:10   ` Michael Witten
2010-08-06 19:58 ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).