Git archive without .gitignore
The built-in archive functionality in Git is handy. Indeed an easy way of making a clean archive of the source. Leaving all Git meta files.
However one common type of Git file will be included in the archive; .gitignore. So to tell the archiver to exclude all .gitignore files you can simply add the file .gitattributes to your repository. Then include these lines in it:
.gitignore export-ignore .gitattributes export-ignore
As a result the export-ignore flag will tell Git to ignore all .gitignore. Additionally we should also exclude the new file .gitattributes by listing it in this file.
Finally you can make an archive of your Git repository excluding all version control system files:
git archive HEAD \ --prefix=myproject/ \ -o myproject.tar.gz