我如何使用git-archive导出特定的提交? [英] How do I export a specific commit with git-archive?
问题描述
pre $ g $ c $ 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
解压后,结果完全一样。
问题
$ b我无法弄清楚为什么或者如何修复它。 $ b
在这两个示例中,都是导出 master 的提示。拿出你的标志和参数,你有:
git archive master
换句话说,通过指定存储在 .git / refs / heads / master 中的任何内容,作为你的树。
解决方案
您需要根据gitrevisions提供一个tree-ish (7)如果你想导出不同的提交。例如,要导出commit 29435bc ,您可以指定:
git archive --format zip - -output /full/path/to/zipfile.zip 29435bc
I asked a similar question before, but it was answered inadequately so I thought I would ask again here but providing more information. I need to get different and older versions of a git repository and I'm having trouble with that. What I've tried is
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
After unzipping both, they end up being exactly the same. I can't figure out why or how to fix it.
The Problem
In both your examples, you are exporting the tip of master. Take out your flags and arguments, and you have:
git archive master
In other words, you're explicitly doing this to yourself by specifying whatever is stored in .git/refs/heads/master as your tree-ish.
The Solution
You need to provide a tree-ish in accordance with gitrevisions(7) if you want to export a different commit. For example, to export commit 29435bc, you could specify:
git archive --format zip --output /full/path/to/zipfile.zip 29435bc
这篇关于我如何使用git-archive导出特定的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!