Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 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?

share|improve this question
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. – 40XUserNotFound Apr 13 '14 at 5:21
up vote 5 down vote accepted

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 -
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.