12

So I have a git repository on my local computer that I want to archive (zip is fine) and upload to my server. Once the file has been uploaded to the server, I will extract the archive. I don't need any of the git information, so I think I need to use git archive but I'm not exactly sure how to use it...and the tutorials haven't been helping.

this is what I've got so far:

cd projectname
git archive master

Then I don't know what to do next. I want to create the archive in this directory:

./../_toDeploy/

How do I do it?

3 Answers 3

11

Any one of the following will work:

git archive --output=../_toDeploy/ArchiveName.zip master
git archive -o ../_toDeploy/ArchiveName.zip master

To add a subdirectory inside the archive,

git archive --output=../_toDeploy/ArchiveName.zip --prefix=MyStuff/ master

See the git-archive manual page for reference.

2
  • is it possible to put the repository inside a directory before archiving it?
    – Andrew
    Dec 10, 2009 at 3:21
  • 1
    Yes, use --prefix. I've added this to the answer. Dec 10, 2009 at 3:26
2

The following will zip up your master branch and put it in the folder you mentioned.

git archive --format=zip master > ../_toDeploy/repo.zip
1

Archive the last commit of your repo and getting rid of everything else (.git etc etc):

git archive --format=tar.gz HEAD > file.tar.gz

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .