git存档与unstaged更改 [英] git archive with unstaged changes
问题描述
我正在构建自己的rpm。通常我使用git archive来从我感兴趣的提交或标记中获取tarball(假设我已经放置了一个标记1.0):
git archive --format = tgz --prefix = product-1.0 1.0> product-1.0.tgz
假设现在我正在做一些本地发展,我还没有做出,我想获得档案;有没有什么办法可以不必提交?
编辑我可以使用像这样的东西:
tar cf product-1.0.tgz --exclude = .git
,但会包含所有的二进制文件和其他未跟踪的文件,我不喜欢...
我不是100%确定这正是你想要的,但是你可以隐藏你使用 git stash create
所做的更改,这会给你一个hash回购的当前状态 - 然后使用 git archive< options>来为其创建存档。 $ HASH
。
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...
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
.
这篇关于git存档与unstaged更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!