I've a directory structure like this:
root/
.git
deploy/
Site/
blah/
more_blah/
something.local
else.development
Rakefile
.gitattributes
Edit: to further clarify the above, directories have a trailing /
and children are indented beneath a directory, so blah
and more_blah
are directories but Rakefile
and .gitattributes
are files, but all four are children of Site
.
I'm running git-archive
from the Site
directory like so:
git archive --format=tar --prefix=git-v0.0.1/ v0.0.1 | gzip > ../deploy/git-v0.0.1.tar.zip
but whatever pattern I put in .gitattributes, the resulting archive always contains Rakefile
. I've tried:
None of them work as I'd expect. Is anyone willing to point out the obvious yet non-obvious to me solution? Any help is much appreciated.
My apologies for not being clear.
Rakefile
is not a directory, just a fileRakefile
is not the only pattern used, but is the only one that doesn't work. It doesn't work whether I have it on its own or with other patterns, and at any place in the file.This is my .gitattributes
(sitting in the directory Site
)
Rakefile export-ignore
*.local export-ignore
*.development export-ignore
*.staging export-ignore
I believe @Jefromi gave the information needed for me to resolve this with his comments, but is too humble to take the credit, and I'd like to keep my acceptance rating at 100% (quite rightly) so I'll give the answer here:
Ok, two things were needed. --worktree-attributes
on its own did not work, but when I moved the .gitattributes
file into the root dir from the Site dir, then it worked. Again, the Git book implies that the file doesn't need to be in the root for it to work (note: dead link)
... (normally the root of your project)
Even the latest version of the docs (2.35.1) there are references to .gitattributes files that aren't in the root of the repo (GIT_WORK_TREE / GIT_DIR) e.g.
not in .gitattributes files in working tree subdirectories
Git does not follow symbolic links when accessing a .gitattributes file in the working tree.
I feel a bit let down by those docs (for once). I also think it's not-what-you'd-think behaviour to have to opt in the file when .gitignore just works, IMO.