I have a git repo: rsh
:
❯ cat rsh/.gitignore
*.o
shell
build/
rsh_history
And I'm attempting to tar it up using tar (GNU tar) 1.32.
The command I'm using is:
❯ gtar cvaf rsh.tar.gz --exclude-vcs-ignores --exclude-vcs rsh
Unfortunately, the build/
directory is included in the tarfile, in spite of build/
being specified in the .gitignore.
❯ gtar cvaf rsh.tar.gz --exclude-vcs-ignores --exclude-vcs rsh
...
rsh/build/
rsh/build/meson-private/
rsh/build/meson-private/install.dat
rsh/build/meson-private/meson.lock
rsh/build/meson-private/sanitycheckc.exe
rsh/build/meson-private/build.dat
rsh/build/meson-private/sanitycheckc.c
rsh/build/meson-private/cmd_line.txt
rsh/build/meson-private/meson_benchmark_setup.dat
rsh/build/meson-private/meson_test_setup.dat
rsh/build/meson-private/coredata.dat
rsh/build/compile_commands.json
rsh/build/rsh
rsh/build/rsh@exe/
rsh/build/.ninja_deps
rsh/build/build.ninja
rsh/build/meson-logs/
rsh/build/meson-logs/meson-log.txt
rsh/build/meson-info/
rsh/build/meson-info/intro-buildsystem_files.json
rsh/build/meson-info/intro-benchmarks.json
rsh/build/meson-info/intro-buildoptions.json
rsh/build/meson-info/intro-dependencies.json
rsh/build/meson-info/intro-installed.json
rsh/build/meson-info/meson-info.json
rsh/build/meson-info/intro-tests.json
rsh/build/meson-info/intro-projectinfo.json
rsh/build/meson-info/intro-targets.json
rsh/build/.ninja_log
...
Curiously enough, the .gitignore itself does get ignored (--exclude-vcs); as well the other files in the .gitignore (rsh_history).
build/*
orbuild/**
rather than justbuild/
.build/**/*
**/build/*
- that's the only way I've been able to get it to exclude an entire subdirectory. note: this will also exclude build/* found in any lower level subdirs.**/build
andbuild
also seem to work (and match non-directories too). I would add these workarounds additionally to the.gitignore
with a comment like# needed for tar --exclude-vcs-ignores