Cómo insertar una etiqueta a un repositorio remoto usando Git?


He clonado un repositorio Git remoto a mi computadora portátil, luego quise agregar una etiqueta, así que corrí

git tag mytag master

Cuando corro git tag en mi portátil se muestra la etiqueta mytag. Luego quiero enviar esto al repositorio remoto para tener esta etiqueta en todos mis clientes, así que corro git push pero recibí el mensaje:

Todo actualizado

Y si voy a mi escritorio y corro git pull y luego git tag no se muestran etiquetas.

También he intentado hacer un cambio menor en un archivo en el proyecto, a continuación, empujarlo al servidor. Después de eso, podría extraer el cambio del servidor a mi computadora de escritorio, pero todavía no hay ninguna etiqueta cuando se ejecuta git tag en mi computadora de escritorio.

¿Cómo puedo enviar mi etiqueta al repositorio remoto para que todos los equipos cliente puedan verla?

10 answers

Para empujar una etiqueta simple :

git push origin <tag_name>

Y el siguiente comando debe presionar todas las etiquetas (no recomendado):

git push --tags
 2594
Author: Trevor,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-14 11:23:38

git push --follow-tags

Esta es una opción sana introducida en Git 1.8.3:

git push --follow-tags

Empuja ambas confirmaciones y solo las etiquetas que son ambas:

  • anotado
  • alcanzable (un antepasado) desde las confirmaciones empujadas

Esto es sano porque:

Es por esas razones que --tags debe evitarse.

Git 2.4 ha agregado la opción push.followTags para activar esa bandera por defecto que puedes configurar con:

git config --global push.followTags true
 717
Author: Ciro Santilli 新疆改造中心 六四事件 法轮功,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-19 08:07:31

Para empujar específico, una etiqueta hacer siguiente git push origin tag_name

 231
Author: solgar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-10-24 14:43:31

Para ampliar La respuesta de Trevor , puede empujar una sola etiqueta o todos sus etiquetas a la vez.

Empuje una sola etiqueta

git push <remote> <tag>

Este es un resumen de la documentación relevante que explica esto (algunos opciones de comando omitidas por brevedad):

git push [[<repository> [<refspec>…]]

<refspec>...

El formato de un parámetro <refspec> es ref la fuente ref <src>, seguido de dos puntos :, seguido del destino ref <dst> {

El <dst> dice cuál ref en el lado remoto se actualiza con esto push push Si :<dst> se omite, la misma referencia que <src> será actualizado...

Tag <tag> significa lo mismo que refs/tags/<tag>:refs/tags/<tag>.

Empuja todas tus Etiquetas a la Vez

git push --tags <remote>
# Or
git push <remote> --tags

Aquí está un resumen de la documentación relevante (algunas opciones de comando omitted for brevity):

git push [--all | --mirror | --tags] [<repository> [<refspec>…]]

--tags

Todos los refs bajo refs/tags se empujan, además de refspecs explícitamente aparece en la línea de comandos.

 76
Author: Community,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 12:10:44

Puedes empujar las etiquetas como esta git push --tags

 41
Author: Fernando Diaz Garrido,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-04 15:40:47

Las etiquetas no se envían al repositorio remoto mediante el comando git push. Necesitamos enviar explícitamente estas etiquetas al servidor remoto usando el siguiente comando:

git push origin <tagname>

Podemos empujar todas las etiquetas a la vez mediante el siguiente comando:

git push origin --tags

Aquí hay algunos recursos para obtener detalles completos sobre el etiquetado de git:

Http://www.cubearticle.com/articles/more/git/git-tag

Http://wptheming.com/2011/04/add-remove-github-tags

 39
Author: Ashutosh Meher,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-10 05:57:19

Puede enviar sus etiquetas locales simplemente con el comando git push --tags.

$ git tag                            # see tag lists
$ git push origin <tag-name>         # push a single tag
$ git push --tags                    # push all local tags 
 12
Author: Sajib Khan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-15 20:53:27

Estoy usando git push <remote-name> tag <tag-name> para asegurarme de que estoy empujando una etiqueta. Lo uso como: git push origin tag v1.0.1. Este patrón se basa en la documentación (man git-push):

OPTIONS
   ...
   <refspec>...
       ...
       tag <tag> means the same as refs/tags/<tag>:refs/tags/<tag>.
 2
Author: Carl G,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-18 18:24:16

Por favor, no lo use, si solo está buscando un comando porque la intención principal de esta solución es presentarle una forma de soluciones !

Para hacer la vida más fácil - escribí un script git-cheat-sheet , que contiene algunos comandos útiles, incluyendo los siguientes:

./git_commands.sh -push_tag TAG_NAME

 0
Author: Monir,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-27 08:50:32

Si está trabajando en una rama:

git push --tags origin branch_name
 -7
Author: Matias,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-04-26 15:39:52