Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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. –  Cupcake Apr 13 at 5:21

1 Answer 1

up vote 1 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

 
discard

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.