Can git archive include the directory that the .git project lives in?
Asked Answered
T

1

6

Can git archive include the directory that the .git project lives in?

For example, let's say my directory structure is like this:

-- /my-project-dir
----- /.git
----- /css
----- index.html
----- scripts.js

By default, when I do a git archive, I end up with a ZIP file like so:

-- my-project-dir.zip
----- /css
----- index.html
----- scripts.js

I'm wondering if there is a way that the archive command can include the parent directory as well, for example:

-- my-project-dir.zip
----- /my-project-dir
-------- /css
-------- index.html
-------- scripts.js
Twit answered 6/2, 2015 at 15:22 Comment(1)
I use git bundle this is just a file which you can then clone from.Mayflower
D
15

Use the --prefix option:

$ pwd
/tmp/foo
$ ls -A
bar  .git
$ git archive --prefix foo/ -o foo.tar master
$ tar tf foo.tar
foo/
foo/bar

Be careful to include the trailing slash in foo/, otherwise you end up with the prefix prepended to each filename!

Diondione answered 6/2, 2015 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.