so git archive --format=tar HEAD will give me a tar archive of the latest commit on the current branch. Is there a version that would include local modifications to tracked files that have not yet been committed?

  • You could always just make a commit, export your archive, then do a mixed reset back to the previous commit to restore your working copy to the same state it was in before you committed. Commented Apr 13, 2014 at 5:21

1 Answer 1


The git way is to commit everything. Remember, branches are cheap.

git checkout -b intermediate-releases/20140414
git commit -m 'Wibble wobble wubble'

Then restore your working copy — I don't know to do that reliably but I'm sure there's a way. Now you can make an archive of the new branch's tip:

git archive intermediate-releases/20140414 | gzip >20140414.tgz

If you really don't want to keep track of that archive (but why not?), you could make a stash, which has the advantage of making it really easy to restore the working copy.

git stash
git archive 'stash@{0}' | gzip >whatever.tgz
git stash pop

If you absolutely don't want to make any change to the working copy, you can use git ls-files to retrieve the list of files and archive these.

git ls-files HEAD | tar -czf whaterver.tgz -T -

You must log in to answer this question.

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