Create GIT repository archive

Sometimes it is necessary to create an archive of the files of a GIT repository, e.g. if you want to sent the files to another person. Therefore you can use the git archive command which creates an archive of the files of the named tree.

Additionally, you can specify the type of archive, in our coming example a tar.gz file extracted from the HEAD tree and stored to the filepath in the end of the shell command.

Enter the GIT repository folder and execute the following command:

git archive --format=tar.gz HEAD > ~/tmp/my-git-archive.tar.gz