git-archive 一个子目录——
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17350939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git-archive a subdirectory --
提问by wildabeast
I'm using git-archive to archive a subdirectory in a git repo, like so:
我正在使用 git-archive 在 git repo 中归档一个子目录,如下所示:
git archive -o ../subarchive.zip HEAD subdir/*
However the resulting archive maintains the subdir/ directory structure, i.e. the contents are:
然而,生成的存档保持 subdir/ 目录结构,即内容是:
subdir/
whatever.js
morestuff.js
When I actually want whatever.js and morestuff.js at the root of the archive.
当我真正想要在存档的根目录下使用 what.js 和 morestuff.js 时。
How do? Thanks.
怎么办?谢谢。
回答by janos
You can do that like this:
你可以这样做:
git archive -o ../subarchive.zip HEAD:subdir
By the way, an easy way to play with the command and see what it will generate is if you use it in this form:
顺便说一句,如果您以这种形式使用它,那么使用该命令并查看它会生成什么的简单方法是:
git archive --format=tar HEAD:subdir | tar t
git archive --format=tar HEAD subdir | tar t
# ... and so on ...
Once you see what you're looking for, you can change the format and use the -o
flag to actually create the archive.
看到要查找的内容后,您可以更改格式并使用该-o
标志来实际创建存档。