Git Checkout 最新标签 [英] Git Checkout Latest Tag

查看:43
本文介绍了Git Checkout 最新标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个 shell 脚本,我正在寻找最新版本的 repo.具体来说,我想把这个过程分成多个步骤.

I'm writing a shell script and I'm looking to checkout the latest version of repo. Specifically I want to break this process apart into multiple steps.

  1. 我想将存储库的最新标签保存到变量中
  2. 打印出查看版本:XX
  3. 查看最新标签

我见过 类似问题,但我不知道如何保存将标签的名称转换为变量(可能是因为我是一个使用 shell 脚本的菜鸟).

I've seen similar questions but I don't see how to save the name of the tag into a variable (probably because I'm a noob with shell scripts).

推荐答案

git describe --tags 应该会给你信息.

bash/shell 脚本:

bash/ shell script:

#!/bin/bash
...
latesttag=$(git describe --tags)
echo checking out ${latesttag}
git checkout ${latesttag}

这篇关于Git Checkout 最新标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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