4

I am trying to create an archive as:

tar -Jcvf shadow-2.7.1.tar.xz shadow/ --exclude-vcs

and I am expecting no .git folder. But

vi shadow-2.7.1.tar.xz 

yeilds

...
shadow/.git/
shadow/.git/index
shadow/.git/objects/
shadow/.git/objects/ab/
...

Mu system is:

which tar
/usr/bin/tar
tar --version
tar (GNU tar) 1.29
uname -sr
Linux 4.9.6-200.fc25.x86_64

What is going wrong here?

4
  • The options should come before the files. tar -Jcvf --exclude-vcs shadow-2.7.1.tar.xz shadow/ should do the job.
    – Jakuje
    Jan 29, 2017 at 16:37
  • @don_crissti sure. But the point is hopefully clear.
    – Jakuje
    Jan 29, 2017 at 18:36
  • @Jakuje Have you tested this? With tar 1.27.1, the location of the option doesn't matter. Has this changed in more recent versions? Jan 29, 2017 at 23:23
  • @Gilles. No, i didnt test it, since it was more like guess and leaving something to the OP. Though thanks for good answer with deeper analysis.
    – Jakuje
    Jan 30, 2017 at 6:35

1 Answer 1

4

Your command works up to GNU tar 1.28. But in version 1.29, the command line parsing mechanism changed. Before, the order of options and operands didn't matter. In recent versions, the order does matter: options that determine which files are selected are position-sensitive and only apply to operands that follow.

1
  • 1
    Just as an example: tar cfz grass_src_snapshot_2020_06_29.tar.gz --exclude-vcs grass_git_src
    – markusN
    Jun 29, 2020 at 9:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .