Using `git archive` with or without `--worktree-attributes` does not properly read `.gitattributes` files if using a relative path in ``. Related github comment: https://github.com/rpm-software-management/tito/pull/445#issuecomment-1450298871 Related stackoverflow discussion: https://stackoverflow.com/questions/52804334/how-to-ignore-files-directories-in-git-archive-and-only-create-an-archive-of-a Git version: `2.39.2` Mwe git repo: Two files: ``` # .gitattributes: .git_archival.txt export-subst ``` ``` # .git_archival.txt: node: $Format:%H$ ``` Commands to reproduce and expected behaviour: ```console $ git archive HEAD:./ --output=test.tar.gz $ tar -axf test.tar.gz .git_archival.txt -O node: 745ce26169fb44e04d91d40ee581cccd591c941e ``` Important: Notice the path `./` given after `HEAD`. Actual output: ```console $ tar -axf test.tar.gz .git_archival.txt -O node: $Format:%H$ ``` It doesn't matter if `.gitattributes` is in a subfolder, or if I change the relative path `./` to a subfolder, the files are still not properly generated. Using `--worktree-attributes` did not have any effect either. According to the documentation, I understand that the expected behaviour with regards to `--worktree-attributes`: - Read the `.gitattributes` of the relative path, e.g. `./sub_dir` regardless of `--worktree-attributes`. (similar behaviour as not passing a relative path) - Include the `.gitattributes` of the top-level path if `--worktree-attributes` is passed Maybe the intended behaviour is to completely ignore all `.gitattributes` unless `--worktree-attributes` is provided, in which case, it does not have the intended behaviour and please include a flag to achieve the above behaviour.