我正在编写一个 shell 脚本,我正在寻找最新版本的 repo。具体来说,我想将这个过程分成多个步骤。
- 我想将仓库的最新标签保存到一个变量中
- 打印出
checkout 版本:XX
- 检查最新标签
我看过 similar questions但我不知道如何将标签的名称保存到变量中(可能是因为我是 shell 脚本的菜鸟)。
最佳答案
# Get new tags from remote
git fetch --tags
# Get latest tag name
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
# Checkout latest tag
git checkout $latestTag
关于Git Checkout 最新标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17414104/