指定git存档的自定义gitattributes文件位置 [英] Specify custom gitattributes file location for git archive

查看:252
本文介绍了指定git存档的自定义gitattributes文件位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想公开git archive,但是有一种让用户要求排除某些文件或glob的方法,因此生成的存档文件不是很大.

I'd like to expose git archive, but have a way for users to ask for some files or globs to be excluded, so the resulting archive file is not very big.

通常,您会将文件/全局列表写入.gitattributes,然后运行git archive.但这意味着只有一个人可以为每个磁盘存储库请求一个存档,因为他们必须将自己的ignore-export列表写入.gitattributes,然后获取该存档,然后再屈服于其他人.同样,这也意味着您以前在此处所做的任何设置都会被破坏.

Normally you'd write the file/glob list to .gitattributes and then run git archive. But this means only one person can ask for an archive per on-disk repository, since they have to write their ignore-export list to .gitattributes, then get the archive, before yielding to someone else. Also this means that whatever settings you had in there previously get clobbered.

有没有一种方法可以写入/tmp/attributes-1或其他类似的临时文件,并告诉git archive读取该.gitattributes文件而不是$repo/.gitattributes?读取文档字符串似乎不是这样.

Is there a way I could write to /tmp/attributes-1 or another similar temp file, and tell git archive to read that .gitattributes file instead of $repo/.gitattributes? Reading the doc string, it doesn't seem like it.

https://git-scm.com/docs/git-archive

https://git-scm.com/docs/gitattributes

推荐答案

您是否错过了 git archive--worktree-attributes 选项?

Did you miss the --worktree-attributes option of git archive?

--worktree-attributes

--worktree-attributes

在工作树的.gitattributes文件中查找属性,如下所示: 好(请参阅属性"部分).

Look for attributes in .gitattributes files in the working tree as well (see the section called "ATTRIBUTES").

...

请注意,默认情况下,属性取自.gitattributes 正在归档的树中的文件. 如果要调整 事实发生后生成输出的方式(例如,您在没有 在.gitattributes中添加适当的export-ignore),调整 检出的.gitattributes文件,必要时使用 --worktree-attributes选项.或者,您可以保留必要的内容 归档您的任何树时应应用的属性 $GIT_DIR/info/attributes文件.

Note that attributes are by default taken from the .gitattributes files in the tree that is being archived. If you want to tweak the way the output is generated after the fact (e.g. you committed without adding an appropriate export-ignore in its .gitattributes), adjust the checked out .gitattributes file as necessary and use --worktree-attributes option. Alternatively you can keep necessary attributes that should apply while archiving any tree in your $GIT_DIR/info/attributes file.

因此,您必须签出一个临时工作树,在此处设置所需的gitattributes并使用--worktree-attributes选项.

So you must checkout a temporary work-tree, set the desired gitattributes there and use the --worktree-attributes option.

这篇关于指定git存档的自定义gitattributes文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆