Creating archives from a tree
Sometimes, it is useful to have a snapshot of the directory structure as specified by a particular commit, but without the corresponding history. This can, of course, be done by checking the particular commit followed by deleting/omitting the .git
folder when creating an archive. But with Git, there is a better way to do this, which is built in so it is possible to create an archive from a particular commit or reference. When using Git to create the archive, you also make sure that the archive only contains the files tracked by Git and not any untracked files or folders you might have in your working directory.
Getting ready
We'll use the same offline-sharing
repository as used in the previous examples in this chapter:
$ git clone https://github.com/dvaske/offline-sharing.git Cloning into 'offline-sharing'... remote: Counting objects: 32, done. remote: Compressing objects: 100% (25/25), done. remote: Total 32 (delta 7), reused 30 (delta 6) Unpacking...