I made a push from a local repository to a remote one, but now realize I needed to have a tag on it. Is there a way to add a tag after the push?
Asked
Active
Viewed 554 times
0
-
https://stackoverflow.com/search?q=%5Bgit-tag%5D+after+push – phd Jun 25 '20 at 20:16
1 Answers
3
You can add a tag at any time. Just add the commit hash to the tag command. For example
git tag -a v1.2 9fceb02
(example taken from the git book, section "Tagging Later")
Then push your tags
git push --tags

Adrian W
- 4,563
- 11
- 38
- 52
-
-
@Eneko What should this advice be good for? `origin` is the default remote anyway. See [doc for git push](https://git-scm.com/docs/git-push). So, why would you advise to push to `origin` if another remote can be configured? – Adrian W Feb 07 '22 at 23:06
-
-
That doesn't make sense. `origin` _is_ the default upstream. So, unless you have defined a different remote you are pushing to `origin` anyway, whether you name that upstream explicitely or use the default. – Adrian W Feb 08 '22 at 11:24
-
Sorry, I think I am not being able to explain properly. The original comment: https://stackoverflow.com/questions/5195859/how-do-you-push-a-tag-to-a-remote-repository-using-git#comment40809114_5195913 – Eneko Feb 08 '22 at 11:49
-
Ah, got it finally ;-) your point is to recommend pushing a single tag instead of pushing all tags. Since that requires a refspec for the tag and one cannot provide a refspec without providing a repository, the repository must be given too (which can be the name of a remote). So, it is not about providing `origin` or not. The advice is to push a single tag instead of using `--all`. That's a valid point, but it would have been helpful to express that intent explicitly (or link to the reference right away). My intent was to push all tags ;-) – Adrian W Feb 08 '22 at 21:54