简体   繁体   中英

How can I create Git tags for a list of releases with timestamps in epoch format?

I have a list of Tags that should be created in some list of lists containing release name and release time in Epoch format.

Release1, 1519124404
Release2, 1508330671
Release3, 1489590989

I should use annotated tags ( https://git-scm.com/book/en/v2/Git-Basics-Tagging ) but I couldn't find a way to add in git tag -a Release1 command a timestamp (preferably in epoch format) so that my Tag references that time in the past of the current branch. I am aware that for Tagging later I could use some commit but this is not something which exists and is not applicable for my use case (since this is some migration from other SCM platform to Git and I only have a list of tags that should be created for my branch).

Any idea? Thanks a lot!

I don't know if you can use commas in tags, but you can use in bash something like that:

git tag -a "Release1-`date +%s`"

It creates a tag in the form Release1-1648822173 , with the epoch time in which you called the command. I'm pretty sure that there's a corresponding command for windows in powershell, or you can use git bash for it.

EDIT:

If you need to link the tag to specific commit date, you can do something like

git tag -a "Release1-`git show -s --format=%ct HEAD`"

If you need to put a tag in a particular date, first you need to find the commit at specific date, and then adding the tag to that date. If you're unsure about the commit, you can use something like git log for viewing all commits in a specific time range.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM