This blog was last modified 543 days before.

Sometimes we need to pack up our project as a compressed file such as an ZIP file. In the same time we only want to exactly ignored the file based on the .gitignore config. So here is where git archive command comes to the stage.

The basic usage of git archive command is like below:

git archive -o archive.zip HEAD

In which:

  • -o / --output Specified the output name
  • -f / --format Specified the compressed file format, e.g.: tar, zip
  • HEAD / [BRANCH_NAME] Specified the branch you want to archive