Archive Your Git Repo

Every few weeks or so, I find myself needing to archive my git repo. Usually it's to send code to someone who has no reason to access the repo directly. They just need a snapshot of the code, with no history information, because they won't be contributing to it.

I also have to provide a snapshot of my code for every module in my Pluralsight courses, so being able to archive my git repo into a zip file is very handy.

For some reason, I can never remember how to do this, and find myself looking it up repeatedly. So I've finally decided to write about it here, in hopes that it will help someone other than just me.

If you want to backup a git repo, completely detaching it from git, use one of the following variations of the git archive command:

Zip File:
git archive --format zip --output /full/path/to/zipfile.zip master 
 
Tar
git archive master | tar -x -C /somewhere/else

Tar / Bzip
git archive master | bzip2 >source-tree.tar.bz2

Note that the archive will not contain the .git directory, but will contain other hidden git-specific files like .gitignore, .gitattributes, etc.

Reference:
http://stackoverflow.com/questions/160608/do-a-git-export-like-svn-export

Comments

Popular posts from this blog

How to copy your Frozen Free Fall progress to a new phone

Ionic vs. Bootstrap - for a Web App

How I Finally Got AdMob and Ionic Framework to Play Nice Together