Git archive with unspecified changes

I create my own rpm. Usually I use the git archive to get the tarball from the commit or tag that interests me (suppose I put the 1.0 tag):

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

Suppose now that I am doing some local events that I have not yet committed, and I want to get the archive; is there any way to get this without committing?

edit I could just use something like this:

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

but this will include all binaries and other junk files that I prefer not to ...

+3
source share
5 answers

I'm not 100% sure, this is exactly what you want, but you can save the changes you made using 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 .

+4
source
 git ls-files | tar Tzcf - archive.tgz 
+5
source

Sorry, this will not be the real answer.

There may be some way, but in fact I do not see much sense in this. The consensus is pretty bright. There is nothign incorrectly committing completely temporary or broken files. Until you press it in public, this is all your local repository. Just create a new branch, commit it, then at some point you can delete this branch, even right away. The only thing you need to be careful about is not pushing this branch to a public repo. The biggest plus is that during commit, you can selectively select which files you want to include. This will allow you to filter out any unwanted binaries, archives, etc. - and with very small details. This is really much more convenient than trying to filter them out on bash and the like.

So, for me, if you are building packages, then you really want to commit. Just because at some point in time you will need to check what the source files are. Or back to him. Exactly what branches and the entire repository have: marking and storing some files in a certain state. The repository is not only for storing the "release code". This is in order to keep everything you need at any given time, in the same condition as at that time.

Therefore, I even recommended a quick branch for these collectors / packages. Do not hide. Steish is something temporary, designed for rapid evaporation. You get a hash for this, but you can easily remove the entire / stash / revision branch. That would definitely destroy the essence of the version. You put it in git to remove it.

Using regular branches and regular commits for any future, you can view or recreate any RPM that you created at any time in history. IMHO, this is a huge plus.

+2
source

Create a branch called archive, add and copy the files I want to track, in addition to what is already tracked in git. Regardless of whether your idle development files, generated documentation, binary files that you do not track in Git, but want an archive, etc. are stored in it

With those that were locked locally, you can now use

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

Please note that the first archive is the command, the second is the name of the branch.

Now return this final completion so that these files are not tracked again.

git reset --soft HEAD~; git reset

Go back to master and delete the archive branch.

+1
source

Next command with

  git archive --output=modified-files.zip HEAD $(git ls-files --modified) 
-one
source

All Articles