在现有的git标签中添加新的提交 [英] Add new commit in the existing git tag

查看:104
本文介绍了在现有的git标签中添加新的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

  git tag -a v1.1 -m'我的1.1版本创建了git标签'

我在推出这些更改之后,对 v1.1进行了一些更改即可。现在,当我推送新的更改并使用
git describe
检查git标记时,它会显示我v1.1-g2dcc97。

我希望我的新提交应该放到现有的标记中。

解决方案

在不破坏重要的Git指南的情况下,您无法将新提交添加到现有标记中:从不(*)修改您发布的提交。



Git中的标签并不意味着可变。然后,您可以在 v1.1 $ b c $ c>并释放一些东西,如 v1.1.1 v1.2 。这样做的一种方法是:
$ b

 #从标签v1.1 $ b创建一个新的分支$ b git checkout -b newbranch v1.1 

#做一些工作并提交它

#从你的工作中创建一个新标签
git tag -a - mTag版本1.1.1,一个bug修复版本v1.1.1

(*)除非你有这是一个非常特殊的理由,只有当你完全理解其含义时,甚至不要养成它的习惯。


I have created git tag as v1.1 using

git tag -a v1.1 -m 'my version 1.1'

and I push that changes after that I made some changes in related to v1.1. Now when I push new changes and check the git tag using git describe it is showing me v1.1-g2dcc97.

I want just my new commit should go into the existing tag.

解决方案

You can't put a new commit into an existing tag without breaking an important Git guideline: Never(*) modify commits that you have published.

Tags in Git aren't meant to be mutable. Once you push a tag out there, leave it alone.

You can, however, add some changes on top of v1.1 and release something like v1.1.1 or v1.2. One way of doing that would be

# Create a new branch from tag v1.1
git checkout -b newbranch v1.1

# Do some work and commit it

# Create a new tag from your work
git tag -a -m "Tag version 1.1.1, a bugfix release" v1.1.1

(*) Unless you have a really super special reason for doing so, and only if you completely understand the implications, and even then, don't make a habit of it.

这篇关于在现有的git标签中添加新的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆