Skip to main content

Posts

Showing posts from April, 2017

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 .gi…