Skip to content

Instantly share code, notes, and snippets.

@andreacioni
Created March 6, 2018 14:42
Show Gist options
  • Save andreacioni/7c0d6a7eb689eacd62215c9f3161344b to your computer and use it in GitHub Desktop.
Save andreacioni/7c0d6a7eb689eacd62215c9f3161344b to your computer and use it in GitHub Desktop.
Checkout git repository to last tag
#!/bin/sh
#From: https://addhewarman.com/2015/01/23/easiest-way-how-to-get-tag-from-remote-github-repository/
LAST_TAG=$(git ls-remote --tags [email protected]:MY_REPOSITORY/"$MY_PROJECT".git | awk '{print $2}' | grep -v '{}' | awk -F"/" '{print $3}' | tail -n 1)
git checkout $LAST_TAG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment