Gabriel
Gabriel

Reputation: 42329

Git: rename tag keeping original date

In this question How do you rename a Git tag? instructions are given to rename an old tag.

I'd like to know it these steps will keep the original date in the edited tag in place.

For example, in my git repo the git tag command shows:

v0.1
v1.0.0-beta

and Github shows:

enter image description here

I want to update the old v0.1 tag to a more descriptive v1.0.0-alpha (which also follows the Semantic Versioning guidelines) but I'd also like to keep the original date (4 Dec 2013) in place.

Is this possible using the commands given in the answer to the question mentioned above? These would be the commands in my case as I understand:

git tag v1.0.0-alpha v0.1
git tag -d v0.1
git push origin :refs/tags/v0.1
git push --tags

Upvotes: 8

Views: 5439

Answers (2)

Yvo
Yvo

Reputation: 19263

In our repository I noticed that one of our older releases had an incorrect version tag. The name was v.1.28.0 instead of v1.28.0. I wanted to correct the issue without somehow messing up the GitHub release.

These are the steps I did to correct it:

  1. check out the incorrect tag, e.g. git checkout v.1.28.0
  2. create a temporary branch, e.g. git checkout -b release/v1.28.0
  3. push the temporary branch, e.g. git push -u origin release/v1.28.0
  4. edit the release in GitHub, change the tag name and point it to the temporary branch
  5. save the changes on GitHub
  6. check out a different branch, e.g. git checkout develop
  7. remove the temporary branch, e.g. git branch -d release/v1.28.0
  8. remove the old incorrect tag, e.g. git tag -d v.1.28.0

Upvotes: 0

Gabriel
Gabriel

Reputation: 42329

Just went ahead and tried, it does keep the date in place.

Upvotes: 3

Related Questions