我如何使用git-archive导出特定的提交? [英] How do I export a specific commit with git-archive?

查看:199
本文介绍了我如何使用git-archive导出特定的提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经问过类似的问题,但答案不够充分,所以我想我会再问一遍,但提供更多信息。我需要获得不同版本的旧版本的git存储库,并且遇到问题。我试过的是

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆