我有一个像这样的目录结构:
root/
.git
deploy/
Site/
blah/
more_blah/
something.local
else.development
Rakefile
.gitattributes
Run Code Online (Sandbox Code Playgroud)
编辑:为了进一步说明上面的内容,目录有一个尾随,子目录/在目录下缩进,所以blah并且more_blah是目录但是Rakefile和.gitattributes文件,但所有四个都是子目录Site.
我正在git-archive从这样的Site目录运行:
git archive --format=tar --prefix=git-v0.0.1/ v0.0.1 | gzip > ../deploy/git-v0.0.1.tar.zip
Run Code Online (Sandbox Code Playgroud)
但无论我放入.gitattributes的模式,生成的存档总是包含Rakefile.我试过了:
它们都没有像我期望的那样工作.是否有人愿意指出明显但不明显的解决方案?任何帮助深表感谢.
我很抱歉不清楚.
Rakefile 不是目录,只是一个文件Rakefile不是唯一使用的模式,但是唯一不起作用的模式.无论我是单独使用它还是使用其他模式,以及文件中的任何位置,它都不起作用.这是我.gitattributes(坐在目录中Site)
Rakefile export-ignore
*.local export-ignore
*.development export-ignore
*.staging export-ignore
Run Code Online (Sandbox Code Playgroud)
我相信 @Jefromi 提供了我用他的评论解决这个问题所需的信息,但他太谦虚了,无法接受这一荣誉,我想将我的接受率保持在 100%(非常正确),所以我会给出答案这里:
好吧,需要两件事。--worktree-attributes其本身不起作用,但是当我将.gitattributes文件从站点目录移动到根目录时,它就起作用了。同样,Git 书籍暗示该文件不需要位于根目录中即可工作(注意:死链接)
...(通常是项目的根目录)
即使是最新版本的文档(2.35.1)也有对不在存储库根目录(GIT_WORK_TREE / GIT_DIR)中的 .gitattributes 文件的引用,例如
不在工作树子目录的 .gitattributes 文件中
访问工作树中的 .gitattributes 文件时,Git 不会遵循符号链接。
我对这些文档感到有点失望(这一次)。我还认为,当 .gitignore 正常工作时,必须选择该文件并不是您所想象的行为,IMO。
不确定这是常见情况,但我无法tests从具有许多嵌套文件夹级别的源树中排除文件夹。如果我只将这一行写到 .gitattributes
tests/* export-ignore
Run Code Online (Sandbox Code Playgroud)
它不起作用,整个目录都保留在存档中。解决方案是为所有子目录级别添加通配符:
tests/* export-ignore
tests/*/* export-ignore
tests/*/*/* export-ignore
tests/*/*/*/* export-ignore
tests/*/*/*/*/* export-ignore
Run Code Online (Sandbox Code Playgroud)
有了这些行,tests目录终于从存档中消失了。
| 归档时间: |
|
| 查看次数: |
13424 次 |
| 最近记录: |