Git Checkout

advertisements

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. I want to save the repositories latest tag into a variable
  2. Print out Checking out version: XX
  3. Checkout the latest tag

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 should give you info.

bash/ shell script:

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