Search code examples
gitgithubgit-svnfetchgit-pull

Git sync with latest release


I have several releases with different tag names (e.g v1.0, v1.0.5 and v2.4 etc). 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?


Solution

  • 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 to get the most recent tag and check that out.