Create a Repository Archive with git

By  on  

Everything about git is amazing. And by "everything", I mean almost everything. As someone that used Perforce and SVN before learning git, I'm willing to ignore a few git annoyances since it makes branching and many other simple tasks easier. One good problem I have with git is that it's so powerful I don't know all of its features.

One feature I recently found out about is its archive feature which allows for exporting an entire repository to a zip or tar file.

# Format:  git archive {branchname} --format={compression} --output={filename}
git archive master --format=tar --output=kuma.tar

git archive some-feature-branch --format=tar --output=kuma.tar

Sure you could use any archiving utility to archive a given repo, this feature allows for quick archiving of any branch or repository state!

Recent Features

  • By
    Write Simple, Elegant and Maintainable Media Queries with Sass

    I spent a few months experimenting with different approaches for writing simple, elegant and maintainable media queries with Sass. Each solution had something that I really liked, but I couldn't find one that covered everything I needed to do, so I ventured into creating my...

  • By
    How I Stopped WordPress Comment Spam

    I love almost every part of being a tech blogger:  learning, preaching, bantering, researching.  The one part about blogging that I absolutely loathe:  dealing with SPAM comments.  For the past two years, my blog has registered 8,000+ SPAM comments per day.  PER DAY.  Bloating my database...

Incredible Demos

  • By
    Do / Undo Functionality with MooTools

    We all know that do/undo functionality is a God send for word processing apps. I've used those terms so often that I think of JavaScript actions in terms of "do" an "undo." I've put together a proof of concept Do/Undo class with MooTools. The MooTools...

  • By
    The Simple Intro to SVG Animation

    This article serves as a first step toward mastering SVG element animation. Included within are links to key resources for diving deeper, so bookmark this page and refer back to it throughout your journey toward SVG mastery. An SVG element is a special type of DOM element...

Discussion

  1. Andreas Krey

    The title is misleading, git archive only puts the tree of a single commit into the .tar file, not the entire branch’s history. Useful for creating a tar file to release a version.

    git bundle is what should be under this heading.

    • Kyll

      Hey, wouldn’t that make another nice entry?

  2. csibar

    Just a small correction: --format does not mean compression. It is – well – just the format of the archive, but it is not compressed at all.

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!