git复制特定版本的存储库

Shu*_*hum 1 git

如果这是一个愚蠢的问题,我是git的新手,请原谅我.我有一个git存储库,我需要将存储库的特定版本复制到它自己的单独目录.复制的版本本身不需要是git存储库,我不需要或不需要历史记录或.git文件夹,只需要存储库对特定提交的外观.

所以说我这样做:

mkdir blah
cd blah
git init
touch flim0
git add .
git commit -a -m "First commit"
touch flim1
git add .
git commit -a -m "Second commit"

mystery-command ~/some-folder 4be82b42cc91ac3801ad72036cec5f88b6a13bd7
Run Code Online (Sandbox Code Playgroud)

其中4be82b42cc91ac3801ad72036cec5f88b6a13bd7是"第一次提交"的哈希,我想〜/ some-folder是一个只包含文件flim0的目录.

这是否容易/可能无需克隆存储库然后签出特定的修订版然后从克隆的存储库中删除.git?

seh*_*ehe 6

 git archive master >specificversion.tar
Run Code Online (Sandbox Code Playgroud)

通过提交标识符替换master

如果你想立即"检查出来",请考虑

 git archive master | (cd /tmp/exportlocation && tar x)
Run Code Online (Sandbox Code Playgroud)

git archive(像往常一样)带来了许多其他有用的选项