Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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...

like image 640
Chris Maes Avatar asked Apr 16 '14 17:04

Chris Maes


People also ask

Does git archive preserve history?

Use Git Archive for Files The available list of formats can be retrieved with the git archive --list command. But the Git archive command includes only the files, not the history of those files. You can also use git archive branch to see the history of your branch/tree.

What is staged and unstaged changes in git?

Unstaged vs Staged changesUnstaged changes are changes that are not tracked by the Git. For example, if you copy a file or modify the file. Git maintains a staging area(also known as index) to track changes that go in your next commit.

How do I archive in git?

To archive a repository, go to your Repository Settings Page and click Archive this repository. Before archiving your repository, make sure you've changed its settings and consider closing all open issues and pull requests.

How do I export a file from git?

Step 1: Go to your git bash. and then to the repo you want to extract or export. Here, we are going to export this repo named 'Ada August-a Challenge' and it's main branch. Step 2: Now export it to your preferred format and location, here we will export it to the same location in .


1 Answers

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.

like image 189
Lewis Eason Avatar answered Sep 28 '22 07:09

Lewis Eason