What command is used to archive a Git repository to a tar file?
Posted by PaulAnd
Last Updated: June 29, 2024
To archive a Git repository to a tar file, you can use the following command:
git archive --format=tar --output=archive-name.tar HEAD
Replace archive-name.tar with your desired output file name. This command will create a tar file containing the contents of the repository at the latest commit (HEAD). If you want to archive a specific branch, tag, or commit, you can replace HEAD with the name of that branch, tag, or commit hash. If you want to create a compressed tar file (e.g., .tar.gz), you can use:
git archive --format=tar.gz --output=archive-name.tar.gz HEAD
Again, adjust the archive-name.tar.gz as needed.