[英]Git sync with latest release
I have several releases with different tag names (eg v1.0, v1.0.5 and v2.4 etc). 我有多个具有不同标签名称的版本(例如v1.0,v1.0.5和v2.4等)。 I only publish a release when my project is at a stable condition.
我仅在我的项目处于稳定状态时才发布发行版。
On a separate machine, I want to pull the latest version that is 'stable', that is to say, the latest release that has been made. 在另一台计算机上,我要提取“稳定”的最新版本,也就是说,取得了最新版本。
Is there a way to achieve this through Git? 有没有办法通过Git实现这一目标?
Make sure you are using tag objects ( git tag -m
), then git fetch
to sync the repos, then do git for-each-ref --sort=taggerdate --format '%(refname:short)' refs/tags | tail -1
确保使用标签对象(
git tag -m
),然后使用git fetch
同步存储库,然后执行git for-each-ref --sort=taggerdate --format '%(refname:short)' refs/tags | tail -1
git for-each-ref --sort=taggerdate --format '%(refname:short)' refs/tags | tail -1
to get the most recent tag and check that out. git for-each-ref --sort=taggerdate --format '%(refname:short)' refs/tags | tail -1
以获取最新标签并进行检查。
If your tags are named consistently with version numbers as your example that v1.0
< v1.0.5
< v2.4
, you can just get the last line from git tag
as the latest. 如果您的标签以版本号一致命名,例如
v1.0
< v1.0.5
< v2.4
,则可以从git tag
中获取最新的最新行。
So the command should be as follows, assuming the remote reference name is origin
因此,假设远程引用名称为
origin
,则命令应如下所示
git fetch --tags origin
git checkout $(git tag | tail -1)
To make it one line command. 要使其成为一行命令。
git fetch --tags origin && git checkout $(git tag | tail -1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.