gitgit-archive

git archive with unstaged changes


I'm building my own rpm's. Usually I use git archive to get a tarball from the commit or tag I'm interested in (suppose I have put a tag 1.0):

git archive --format=tgz --prefix=product-1.0 1.0 > product-1.0.tgz

suppose now I am doing some local developments that I haven't committed yet and I want to get an archive; is there any way to obtain this without having to commit?

edit I could just use something like this:

tar cf product-1.0.tgz --exclude=.git

but that will include all binaries and other untracked files which I prefer not...


Solution

  • I'm not 100% sure this is exactly what you want, but you can stash the changes you've made with git stash create, which will give you a hash for the current state of the repo - and then create an archive for it with git archive <options> $HASH.