How to prevent macOS hidden files like ._* when creating .tgz archives?

Hi everyone,
I’m on macOS and every time I create a .tgz archive using tar, it includes annoying hidden files like ._filename, which are AppleDouble metadata files.

This causes issues when I try to train my model, when I try to access pictures table.

  1. How can I prevent these ._* files from being added in the archive in the first place?
  2. What’s the cleanest way to remove them before creating the .tgz?

Any best practices or reliable shell scripts you use would be super helpful.
Thanks a lot!