unable to curl a git tag

ぃ、小莉子 提交于 2019-12-07 08:25:08

问题


I want to curl a git tag through the command line:

curl -O http://someurl

But when I try to untar the file it is broken? Do anyone know what is the problem?


回答1:


You can curl a git tag from a git repos hosting service like GitHub, because it has a dedicated tarball service (like Nodeload) which provides tar (or zip). But not any other git repo out there has that same service.

See "Having trouble downloading Git archive tarballs from Private Repo" for a concrete example with GitHub (or this curl GitHub tutorial):

curl -sL --user "${username}:${password}" https://github.com/$account/$repo/tarball/$tag_name > tarball.tar

On a public repo:

curl -L https://github.com/pinard/Pymacs/tarball/v0.24-beta2 | tar zx



回答2:


git itself doesn't provide a http-interface. A solution is to use git archive instead

git clone http://example.com/myrepo.git
git archive mytag > myrepo-mytag.tar.gz



回答3:


If you need to fetch only the minimum necessary,

git init temp
cd temp
git remote add x http://example.com/repo.git
git fetch x sometag --depth=1
git archive FETCH_HEAD > ../repo.sometag.tgz
cd ..
rm -rf temp

will do ya



来源:https://stackoverflow.com/questions/14101317/unable-to-curl-a-git-tag

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