Re: Feature request: Allow extracting revisions into directories
- From
- Konstantin Khomoutov <kostix+git@007spb.ru>
- Date
- Feb 3, 2013, 23:26 UTC
- Message-ID
- <20130203232651.GV5210@localhost.localdomain>
- In-Reply-To
- <1359901085.24730.11.camel@t520>
On Sun, Feb 03, 2013 at 03:18:05PM +0100, Robert Clausecker wrote:
Show 12 quoted lines
> git currently has the archive command that allows to save an arbitrary > revision into a tar or zip file. Sometimes it is useful to not save this > revision into an archive but to directly put all files into an arbitrary > directory. Currently this seems to be not possible to archive directly; > the only way I found to do it is to run git archive and then directly > unpack the archive into a directory. > > git --git-dir REPO archive REVISION | tar x > > It would be nice to have a command or simply a switch to git archive > that allows the user to put the files of REVISION into a directory > instead of making an archive.
You could use plumbing commands combined with a throwaway custom index file and a separate work tree which will receive the tree at REVISION:
export GIT_WORK_TREE=/path/to/dest/directory export GIT_DIR=/path/to/repo/.git export GIT_INDEX_FILE="$GIT_WORK_TREE/.index" git read-tree REVISION git checkout-index -a rm -f "$GIT_INDEX_FILE"