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. – 40XUserNotFound Apr 13 '14 at 5:21

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 -

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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