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:


How do I do it?


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.

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

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

git archive --format=zip master > ../_toDeploy/repo.zip
| improve this answer | |

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.