Sample Header Ad - 728x90

GNU tar not ignoring directories in gitignore with --exclude-vcs-ignores

5 votes
2 answers
3614 views
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).
Asked by xrisk (701 rep)
Aug 24, 2019, 05:48 AM
Last activity: Feb 12, 2020, 12:44 PM