Tarballing without Git metadata

You can try directly with the tar option --exclude-vcs:

--exclude-vcs:
          Exclude version control system directories

For example:

tar cvfj nameoffile.tar.bz2 directory/ --exclude-vcs

It works with Git.


You will get a nasty surprise when the number of files increase to more than one xargs command: Then you will first make a tar file of the first files and then overwrite the same tar file with the rest of the files.

GNU tar has the --exclude option which will solve this issue:

tar cvf ~/app.tar --exclude .git --exclude "*.log" .

Try something like this:

git archive --format=tar -o ~/tarball.tar -v HEAD

Add your .log files and everything else you don't want to be packed to your .gitignore file.


To exclude version control system directories:

tar --exclude-vcs

This will exclude svn, git metafiles etc.