git export
could you please provide a simple solution to save a tree object into an arbitrary location?
I found some hints, that it would be possible by missusing either git checkout-index or git-archive, but I think that it shouldn't require that much GIT FU to do such a simple thing.
Thanks,
Thomas Koch, http://www.koch.ro
Thomas Koch venit, vidit, dixit 10.08.2009 18:22:
Quoted 9 lines
could you please provide a simple solution to save a tree object into an arbitrary location?
I found some hints, that it would be possible by missusing either git checkout-index or git-archive, but I think that it shouldn't require that much GIT FU to do such a simple thing.Thanks,
Thomas Koch, http://www.koch.ro
To serve you with an explicit command line, it's really only
git archive HEAD | tar -C wheretoexport/ -xf-
which you need to issue from within your git repo. Instead of HEAD, you can use any "treeish", for example the name of a branch, which need not be checked out. You can add path arguments after the treeish if you want to export only parts of your repo.
Note that in true unix philosophy, git archive does the (git specific) exporting only and leaves the importing into the file system (saving) to the proper tool. I mean, would you rather use cp -r or pipes with tar -x/tar -c or cpio -i/-o in order to copy a tree? ;)
Cheers,
Michael
Quoted 4 lines · Thomas Koch
could you please provide a simple solution to save a tree object into an arbitrary location?
I found some hints, that it would be possible by missusing either git checkout-index or git-archive, but I think that it shouldn't require that much
If you are talking about a tree object, then git-archive is what you want. It was invented almost for this exact purpose, but unlike "export" that would only copy to a directory, you can get a tarball out of it when you do not want to expand the result into a directory; it is more versatile form. The manual page for the command has an example (look for "/var/tmp") so I won't repeat the cut-and-paste recipe here.
If you are not talking about a tree object but is talking about the contents recorded in your index, checkout-index with the --prefix option may be what you want. The manual page for the command has an example (look for "--prefix=git-export-dir/") so I won't repeat it here.
Hi,
Quoted 6 lines · Thomas Koch
could you please provide a simple solution to save a tree object into an arbitrary location?
I found some hints, that it would be possible by missusing either git checkout-index or git-archive, but I think that it shouldn't require that much GIT FU to do such a simple thing.
You can check out Documentation/install-doc-quick.sh and find that something like
GIT_INDEX_FILE=.git/tmp export GIT_INDEX_FILE git read-tree $TREE git checkout-index -a -f --prefix=/the/path unset GIT_INDEX_FILE
should work.
Hth,
Dscho
Hey Thomas,
Quoted 2 lines · Thomas Koch
could you please provide a simple solution to save a tree object into an arbitrary location?
This has been requested a few times and I have no idea what the development status of it is. Most people seem to recommend just making an alias around git checkout-index.
Quoted 3 lines
I found some hints, that it would be possible by missusing either git checkout-index or git-archive, but I think that it shouldn't require that much GIT FU to do such a simple thing.
It's not really a misuse, as the [man page itself](http://www.kernel.org/pub/software/scm/git/docs/git-checkout-index.html) recommends using checkout-index as a way to export an entire tree. Until someone decides that it's worth making the porcelain command (like you perhaps) then I think you can just stick with checkout-index knowing you're not abusing anything.
Signature · 6 lines
In Christ, Timmy V. http://burningones.com/ http://five.sentenc.es/ - Spend less time on e-mail
Hi Tim,
thanks for your explanation. Still I don't get how to do it with git checkout- index. The man page says "Just read the desired tree into the index", but I don't know what is meant by this.
Quoted 14 lines
Hey Thomas,
Quoted 2 lines · Thomas Koch
could you please provide a simple solution to save a tree object into an arbitrary location?
This has been requested a few times and I have no idea what the development status of it is. Most people seem to recommend just making an alias around git checkout-index.
Quoted 3 lines
I found some hints, that it would be possible by missusing either git checkout-index or git-archive, but I think that it shouldn't require that much GIT FU to do such a simple thing.
Quoted 6 lines
It's not really a misuse, as the [man page itself](http://www.kernel.org/pub/software/scm/git/docs/git-checkout-index. html) recommends using checkout-index as a way to export an entire tree. Until someone decides that it's worth making the porcelain command (like you perhaps) then I think you can just stick with checkout-index knowing you're not abusing anything.
Thomas Koch, http://www.koch.ro
Quoted 3 lines · Thomas Koch
thanks for your explanation. Still I don't get how to do it with git checkout- index. The man page says "Just read the desired tree into the index", but I don't know what is meant by this.
No problem. That phrase gave me some trouble the first time I read it too. All it means is 'do a git checkout of the branch that you want to export'. git checkout-index will then do an export of the contents the branch that you currently have checked out.
Junio and Dscho's comments are possibly salient as well.
Signature · 6 lines
In Christ, Timmy V. http://burningones.com/ http://five.sentenc.es/ - Spend less time on e-mail