0

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).

  • it might be a difference in interpretation of the .gitignore file. try either build/* or build/** rather than just build/. – cas Aug 24 at 6:59
  • @cas neither of those worked; not did build/**/* – Rishav Aug 24 at 7:01
  • try **/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. – cas Aug 24 at 7:27
  • **/build and build 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 – Freddy Aug 24 at 7:34
  • if you write that up as an answer, i'll upvote it and you can accept it in a day or so. – cas Aug 24 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.