1
find /home/karl/dev/beer/ -printf "%P\n" | tar --exclude='./.git' -czf beer.tgz --no-recursion -C /home/karl/dev/beer/ -T -

The command still includes the .git directory.

Zanna
  • 70,465

2 Answers2

0

You can try to exclude the directory in find like this:

find /home/karl/dev/beer -path .git -prune -printf "%P\n" | tar -czf beer.tar.gz --no-recursion  -T -

You can check also this discussion.

0

from man find:

 -printf
 ....
 %P     File's name with the name of the starting-point under which it was found 
        removed.

So you are excluding a directory that doesn't exist in your output. If you look at the output of your find command before you pipe it (generally a good idea), you will see it has no leading ./. So, you should use --exclude='.git' not ./.git

But rather than using find for this, you might want to use globstar to make globbing recursive:

shopt -s globstar
tar --exclude='.git' -czvf beer.tar.gz /home/karl/dev/beer/**
Zanna
  • 70,465