Increment last Git tag by 1 or by.1
<p>Trying to figure out a way to increment a tag that I need to delete automatically via the CI build so that it is up to date. </p>

<p>Roughly, compile the code, then it gets tagged. Then it commits. Obviously would be easier to have it correct the first time but not an option to fix at current time. Found this and looks promising: </p>

<pre><code># Get new tags from remote
git fetch --tags

# Get latest tag name
latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
</code></pre>

<p>But is there a way to </p>

<pre><code># Checkout latest tag
git tag -d $latestTag
</code></pre>

<p>And then have it increment by one. So if it was v1.0.1 it would then be v1.0.2?</p>

<pre><code>latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
git tag -a $latestTag ++1 -m "Release $latestTag ++1"
</code></pre>