Create a tar archive from the contents of a specific directory

git archive

git archive --output={{path/to/file.tar}} HEAD:{{path/to/directory}}

click the source code to copy install git archive on any operating system with command-not-found.com