git: check out a tag, modify something, then tag it again

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;


// 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

Need Your Help

delete row conditional on value in other rows

r data.frame

I have a dataset looking similar to this one

Swift - better way for Map Annotations

map swift annotations

Hey i m currently working on a small app but my memory usage is ways to high.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.