我想在远程服务器上执行以下命令:
git archive --prefix="$tag/" --remote="ssh://$gitserver/var/git/$repo" "$tag" | tar -xvf-
问题是我不知道$tag
是什么。它应该是 git describe --abbrev=0
在最新克隆上的输出,但我不知道如何在不对存储库进行本地克隆的情况下获取该信息。是否可以在不制作本地克隆的情况下执行此操作?
最佳答案
#!/usr/bin/awk -f
BEGIN {
FS = "[ /^]+"
while ("git ls-remote " ARGV[1] "| sort -Vk2" | getline) {
if (!sha)
sha = substr($0, 1, 7)
tag = $3
}
while ("curl -s " ARGV[1] "/releases/tag/" tag | getline)
if ($3 ~ "commits")
com = $2
printf com ? "%s-%s-g%s\n" : "%s\n", tag, com, sha
}
示例输出
$ git-describe-remote.awk https://github.com/stedolan/jq
jq-1.4-148-g89791a0
关于git - 有没有简单的方法来 "git describe"远程存储库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39841164/