-1

Is there a way to keep a checkout updated between tags, and only tags?

Ideally, I want to go into the checkout's directory, type "git pull", have the command fail if there are no new tags in the repo or pull all the code down from that newer tag.

Is this a bad idea? Maybe, because I can't find a solution, no one actually does this. Are there any issues executing this way?

Bill Riley
  • 97
  • 1
  • 9
  • `git fetch -a`, parse the output, then checkout the latest tag? – guido May 18 '14 at 01:10
  • You can get the necessary data without fetching, `git ls-remote --tags origin` does that, and you can match its format locally with `git for-each-ref refs/tags --format="%(objectname)$(printf '\t')%(refname)"`. – jthill May 18 '14 at 03:22
  • I looked at fetch and describe, hacked my way around something crappy. ls-remote is super nice. – Bill Riley May 18 '14 at 19:07

1 Answers1

1

You could use the following script:

git fetch origin
currentTag=$(git describe --tags --abbrev=0)
lastTag=$(git describe --tags --abbrev=0 origin/master)
if [ $currentTag != $lastTag ]; then
  git checkout $lastTag;
  exit 0
else
  exit 1
fi
gturri
  • 13,807
  • 9
  • 40
  • 57