我之前问过类似的问题,但没有得到充分回答,所以我想我会在这里再问一次,但提供更多信息。我需要获取不同的旧版本的 git 存储库,但我遇到了麻烦。我试过的是
git checkout master~X
git archive --format zip --output /full/path/to/zipfile.zip master
git checkout master
git checkout master~Y
git archive --format zip --output /full/path/toDifferent/zipfile.zip master
git checkout master
解压缩后,它们最终完全相同。我不知道为什么或如何解决它。
最佳答案
问题
在您的两个示例中,您都在导出master 的提示。拿出你的标志和参数,你有:
git archive master
换句话说,您通过将存储在 .git/refs/heads/master 中的任何内容指定为您的 tree-ish 来明确地对自己执行此操作。
解决方案
您需要根据 gitrevisions(7) 提供树状图如果你想导出不同的提交。例如,要导出提交 29435bc,您可以指定:
git archive --format zip --output /full/path/to/zipfile.zip 29435bc
关于git - 如何使用 git-archive 导出特定的提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11018411/