tags:

views:

57

answers:

1

I'm very confused about how to use git archive.

I have a git repository with folder Foo, Bar and Baz at the top level. I need to export folder Foo in a SVN-ish sort of way for quick test deployment.

I learned that I could use git-archive in an SVN-ish export sort of way.

But here's the thing, The following works fine:

git archive master | tar -x -C ~/destination

it results in Foo, Bar, Baz folders in the destination folder.

However, the following will error out with 'fatal not a valid object name':

git archive master/foo | tar -x -C ~/destination

Looking as the synopsis for the git archive program I see that it can take a <tree-ish> [path] as a parameter:

git archive [--format=<fmt>] [--list] [--prefix=<prefix>/] [<extra>]
                     [-o | --output=<file>] [--worktree-attributes]
                     [--remote=<repo> [--exec=<git-upload-archive>]] <tree-ish>
                     [path...]

if master/foo is not tree-ish, then what is? :(

+3  A: 

You probably want

git archive master foo | tar -x -C ~/destination

The expression master/foo does not make sense: master is a branch name and foo is a directory name, as I presume. If you would like to know what a "treeish" is in git, Google is your friend: Git Treeishes

Sven Marnach
That worked! Thanks!
DKinzer