Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 8 down vote accepted

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.

share|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
share|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

share|improve this answer

You must log in to answer this question.

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