git:签出标签,修改内容,然后再标记 [英] git: check out a tag, modify something, then tag it again

查看:1156
本文介绍了git:签出标签,修改内容,然后再标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我觉得我应该知道这一点,但我感到困惑。

我在github上分配了一个仓库。我需要的是签出一个标签(称为'v1.0.5'),修改文件上的语句,用一个名为'1.0.5'的新标签(不带'v')重新标记该状态,然后执行主人也一样。

让我更清楚。我将EightMedia的Hammer.js从一个已命名的AMD模块更改为匿名模块。



我必须更改的唯一文件是 src / outro的.js 文件不会从标记v1.0.5更改为HEAD。



我想更改

  // requireJS模块定义
if(typeof window.define ==='function'&& window.define.amd){
window.define('hammer',[],function(){
return Hammer;
});



<$ p (函数window.define ==='函数'&& window.define.amd){
window.define(函数){$ p $ // requireJS模块定义
if (){
return Hammer;
});
}

我想要的是:checkout v1.0.5,更改该文件并推送回放的方式是我有一个标记 1.0.5 ,它包含v1.0.5的精确内容以及更改。标签必须推到远程。

然后,结帐大师,再次更改文件并再次将其重新推送给主人。



结账v1.0.5时我很迷茫,并且处于分离的HEAD状态。提交后,我在哪里推送修改?我怎样才能标记它们并将标签推送到远程? 首先,使用原始标签结帐:

b
$ b

  git checkout v1.0.5 

这会让你处于分离的HEAD状态 - 你的提交不会特别的进入任何分支。这听起来像你想要的!



现在,进行更改,分级并提交。

  git commit -a -m提交信息

仍然处于分离的HEAD状态,但是您处于新的提交状态 - 即具有所需更改和历史记录的提交。所以标记它!

  git tag 1.0.5 

推回遥控器(假设您仍然是起源地):

  git push origin 1.0.5 

这会将标签本身(1.0.5)以及所有必要的提交历史记录。



请注意,您的更改不会被包含在 other 之外的任何地方。根据你的问题,我认为这就是你想要的,但是如果你需要合并回主人,你可以按照以下步骤进行:

  git checkout master 
git merge 1.0.5


I feel like I should know this, but I'm getting confused.

I forked a repository on github. What I need is to checkout a tag (called 'v1.0.5'), modify a statement on a file, re-tag that state with a new tag called '1.0.5' (without the 'v'), then do the same changes to master.

Let me be clearer. I'm changing EightMedia's Hammer.js from a named AMD module to an anonymous one.

the only file I have to change is src/outro.js. The file doesn't change from tag v1.0.5 to HEAD.

I want to change

// requireJS module definition
if(typeof window.define === 'function' && window.define.amd) {
    window.define('hammer', [], function() {
        return Hammer;
    });
}

to

// requireJS module definition
if(typeof window.define === 'function' && window.define.amd) {
    window.define(function() {
        return Hammer;
    });
}

What I want is: checkout v1.0.5, change that file, and push the repo in a way that I have a tag 1.0.5 that comprises the exact content of v1.0.5, plus the changes. The tag must be pushed to remote.

Then, checkout master, change the file again and push it again to master.

I'm quite lost when checkout v1.0.5 and I get in the detached HEAD state. After committing, where do I push the modifications? And how can I tag them and push tags to remote?

解决方案

First, checkout using the original tag:

git checkout v1.0.5

This will put you in detached HEAD state - your commits won't go to any branch in particular. This sounds like what you want!

Now, make your changes, stage them, and commit.

git commit -a -m "Commit message"

You're still in detached HEAD state, but you're at a new commit - the one that has both the changes and history you want. So tag it!

git tag 1.0.5

To push back to the remote (assuming yours is still named origin):

git push origin 1.0.5

This will push the tag itself (1.0.5) as well as all the necessary commit history it points to.

Note that your change won't be included anywhere other than this tag. Based on your question, I think that this is what you want, but if you do need to merge back to master, you can follow with:

git checkout master
git merge 1.0.5

这篇关于git:签出标签,修改内容,然后再标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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