【问题标题】:git archive from a specific hash from remote来自远程特定哈希的 git 存档
【发布时间】:2017-04-30 08:23:48
【问题描述】:

我正在尝试从一个远程存储库中获取一个目录,但我只想从特定哈希中获取该文件。如果我将 git archive 与 HEAD 一起使用,一切都很好,但是当我尝试使用特定的哈希时:

git archive -v --format tar --remote=ssh://....myrepo.git agithash afile > output.tgz

但我得到了

fatal: sent error to the client: git upload-archive: archiver died with error
remote: fatal: no such ref: 9a9c309
remote: git upload-archive: archiver died with error

所以我读到我可以像这样使用另一个上传存档:

git archive -v --format tar --remote=ssh:.....myrepo.git --exec="/usr/local/bin/git upload-archive" ahash afile > output.tgz

它也没有工作。我认为是因为 BitBucket 不支持 https://confluence.atlassian.com/bitbucketserverkb/git-upload-archive-archiver-died-with-error-779171761.html

所以我想知道:还有其他简单的方法可以做到这一点吗?

【问题讨论】:

    标签: git hash bitbucket commit archive


    【解决方案1】:

    如果该提交被分支引用,您可以直接在正确的提交处进行浅层克隆:

    git clone <url> --depth=1 --branch <branch_name> -- <folder_name>
    

    然后存档。

    但出于安全原因,您不能directly get or clone a specific commit

    【讨论】:

      猜你喜欢
      • 2018-09-22
      • 2022-11-20
      • 2014-05-11
      • 2015-07-07
      • 2012-12-31
      • 1970-01-01
      • 2018-06-21
      • 2011-04-03
      • 2022-01-08
      相关资源
      最近更新 更多