先移动标签一次提交 [英] Move tag one commit ahead

查看:97
本文介绍了先移动标签一次提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有一个分支( master )的仓库。 添加:我是我回购的唯一贡献者(抱歉,我忘记提及这一点)



我最近添加了一个 tag ,本地和推送到Github,做了我虽然是最后必要的提交,但现在我意识到我应该做了一个更改/提交。 b
$ b

所以我得到的是:

 提交124 
提交125
commit 126< - tag v1.0
commit 127

我想将 v1.0 标记移到本地和Github中的下一个提交,即: 127 p>

我该怎么办? 你有去过吗?图书俱乐部的成员并不都使用同一版本的本周之书?这是一场噩梦,对吧?移动标签基本上会让你处于相同的状况。



如果您认为您的存储库是一本记录项目进度的书,您可以将标签想象为章节标题




分享后将标签移至其他提交内容就像告诉您所有的图书俱乐部好友


你知道吗,伙计?我们迄今为止所使用的这本书的版本现在已经过时,因为我已经单独规定第8章现在应该开始,而不是第126页,而是第128页。




不好。移动标签是历史重写的一种形式,您不应该重写已共享的历史记录。这是让你的合作者失望的最可靠的方法。此外,您还写了:


我是我回购的唯一贡献者[/ b]
blockquote>

现在可能是这样,但如果其他人可以访问您的GitHub仓库(例如,如果它是公开的),其中一些人可能已经分叉或克隆它(尽管有一个方式),并且如果您重写历史记录,您可能会冒风险。 p>




如果您100%确定要移动该标签,Git确实允许您这样做。在这里,您可以使用

  git tag --force v1.0< ID-of-commit-127> 

然后您必须强制推送该标签,方法是使用

  git push --force --tags 

但是,再次强调,继续前进 ...


I have a repo with only one branch (master). ADD: I'm the only contributor to my repo (sorry, I forgot to mention this)

I've recently added a tag, both locally and pushed to Github, after making what I though was the last necessary commit, but now I realize I should have made one more change/commit.

So what I have is:

commit 124
commit 125
commit 126 <-- tag v1.0
commit 127

and I want to move the v1.0 tag to the next commit, ie: 127, both locally and in Github.

How can I do tat?

解决方案

Have you ever been to a book club where members do not all use the same edition of the "book of the week"? It's a nightmare, right? Moving a tag would essentially put you in the same situation.

If you think of your repository as a book that chronicles progress in your project, you can think of a tag as a chapter heading.

Moving a tag to a different commit after sharing it is like telling all your book-club buddies

You know what, guys? The edition of the book we've all been using so far is now obsolete, because I have solely decreed that chapter 8 shall now start, not on page 126, but on page 128.

Not good. Moving a tag is a form of history rewriting, and you shouldn't rewrite history that has been shared. It's the surest way to piss your collaborators off. Besides, you write

I'm the only contributor to my repo [...]

That may be true for now, but if other people than you have access to your GitHub repository (e.g. if it's public), some of them may already have forked or cloned it (although there is a way to find out), and you run the risk of pissing them off if you rewrite history.


If you're 100% sure that you want to move that tag anyway, Git does allow you to do it. Here, you could use

git tag --force v1.0 <ID-of-commit-127>

and then you would have to force push that tag, using

git push --force --tags

But again, think twice before going ahead...

这篇关于先移动标签一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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