git archive from a specific hash from remote

岁酱吖の 提交于 2019-12-08 06:29:52

问题


I am trying to get one directory from one remote repository but I only want to get that file from a specific hash. If I use git archive with HEAD everything is OK but when I try with a specific hash:

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

But I'm getting

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

So I've read that I could use another upload-archive like this:

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

It didn't work either. I assume is because BitBucket does not support it as per https://confluence.atlassian.com/bitbucketserverkb/git-upload-archive-archiver-died-with-error-779171761.html

So I wonder: is there another simple way to do this?


回答1:


If that commit is referenced by a branch, You could do a shallow clone directly at the right commit:

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

And then make an archive.

But you cannot directly get or clone a specific commit, for security reason.



来源:https://stackoverflow.com/questions/41152200/git-archive-from-a-specific-hash-from-remote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!