Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swap "Latest release" on github

Tags:

git

github

I have a repository on a github.

Here is the graph: enter image description here

Here is my action sequence:

  1. Make 5 commits and push them

  2. Add a tag v0.2.0 (git tag -a v0.2.0 -m "release 0.2.0")

  3. Push the tag (git push --tags origin master)

  4. Make a release by Draft a new release button on github site. I have selected v0.2.0 tag and got https://github.com/n1k1ch/PrototypeGit/releases/tag/v0.2.0

  5. Add a tag to previous commit (git tag -a v0.1.0 b217332279 -m "release 0.1.0")

  6. Push the tag (git push --tags origin master)

  7. Make a release by Draft a new release with v0.1.0 tag and got https://github.com/n1k1ch/PrototypeGit/releases/tag/v0.1.0

So, v0.1.0 tag become Latest release

Question:

Am I able to swap v0.1.0 release with v0.2.0 release, to v0.2.0 become the Latest release?


P.S. googling "github swap release" didn't help


Edit:

Thanks to @Chris, i did it. One small note - on Windows i used:

SET GIT_COMMITTER_DATE="2014-04-02 23:00" git tag -a v0.1.0 b217332279 -m "release 0.1.0" git push --tags origin master 

Just if someone interested, after this i see following: tag v0.1.0 re-timed

I opened v0.1.0 and press Publish release The result is: latest release "swapped"


Also i have received the answer from [email protected]:

This is expected behavior. We're going by the date of your v0.1.0 release, not the date of the last commit. Here's a good blog post about changing the date of an annotated tag: http://sartak.org/2011/01/replace-a-lightweight-git-tag-with-an-annotated-tag.html

like image 255
n1k1ch Avatar asked Apr 02 '14 20:04

n1k1ch


People also ask

What is new release in GitHub?

What Are Releases In GitHub? Releases in GitHub are the one-stop solution from GitHub to provide software packages in binary files along with their release notes for every release of the software. Binary files are a great way to give the user a version of the software in the form of code until a particular point.

How do I remove a tag from GitHub?

You can delete a release by going to the release (as if you were viewing it), then clicking the Delete Release button.


1 Answers

I am not aware of any way to do this directly in GitHub. The "latest release" is determined from the timestamps on your tags, not from the semantics of their names.

In the past I have solved this problem on my own personal projects by deleting the problematic older tag:

git tag -d v0.1.0 git push --delete origin v0.1.0 

and recreating it with a fake date:

GIT_COMMITTER_DATE="2013-12-31 00:00" git tag -a v0.1.0.1 b217332279 -m "release 0.1.0.1" git push --tags origin master 

This is documented in the manpage for git-tag:

On Backdating Tags

If you have imported some changes from another VCS and would like to add tags for major releases of your work, it is useful to be able to specify the date to embed inside of the tag object; such data in the tag object affects, for example, the ordering of tags in the gitweb interface.

To set the date used in future tag objects, set the environment variable GIT_COMMITTER_DATE (see the later discussion of possible values; the most common form is "YYYY-MM-DD HH:MM").

For example:

$ GIT_COMMITTER_DATE="2006-10-02 10:31" git tag -s v1.0.1 

Note that this same manpage strongly recommends against reusing the same tag name:

On Re-tagging

What should you do when you tag a wrong commit and you would want to re-tag?

If you never pushed anything out, just re-tag it. Use "-f" to replace the old one. And you're done.

But if you have pushed things out (or others could just read your repository directly), then others will have already seen the old tag. In that case you can do one of two things:

  1. The sane thing. Just admit you screwed up, and use a different name. Others have already seen one tag-name, and if you keep the same name, you may be in the situation that two people both have "version X", but they actually have different "X"'s. So just call it "X.1" and be done with it.

  2. The insane thing. You really want to call the new version "X" too, even though others have already seen the old one. So just use git tag -f again, as if you hadn't already published the old one.

However, Git does not (and it should not) change tags behind users back. So if somebody already got the old tag, doing a git pull on your tree shouldn't just make them overwrite the old one.

If somebody got a release tag from you, you cannot just change the tag for them by updating your own one. This is a big security issue, in that people MUST be able to trust their tag-names. If you really want to do the insane thing, you need to just fess up to it, and tell people that you messed up. You can do that by making a very public announcement saying:

Ok, I messed up, and I pushed out an earlier version tagged as X. I then fixed something, and retagged the fixed tree as X again.

If you got the wrong tag, and want the new one, please delete the old one and fetch the new one by doing:

git tag -d X   git fetch origin tag X 

to get my updated tag.

You can test which tag you have by doing

git rev-parse X 

which should return 0123456789abcdef.. if you have the new version.

Sorry for the inconvenience.

Does this seem a bit complicated? It should be. There is no way that it would be correct to just "fix" it automatically. People need to know that their tags might have been changed.

I would only reuse the same tag if your project is relatively isolated and you can reliably contact everybody who may be using the code.

For more details about deleting remote tags have a look at this question.

like image 54
Chris Avatar answered Sep 29 '22 04:09

Chris