Skip to content

Instantly share code, notes, and snippets.

@medusar
Forked from danielestevez/gist:2044589
Created October 14, 2016 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save medusar/7b8c4f0a010eaa4a7183c3181ba8d621 to your computer and use it in GitHub Desktop.
Save medusar/7b8c4f0a010eaa4a7183c3181ba8d621 to your computer and use it in GitHub Desktop.
GIT Commit to an existing Tag
1) Create a branch with the tag
git branch {tagname}-branch {tagname}
git checkout {tagname}-branch
2) Include the fix manually if it's just a change ....
git add .
git ci -m "Fix included"
or cherry-pick the commit, whatever is easier
git cherry-pick {num_commit}
3) Delete and recreate the tag locally
git tag -d {tagname}
git tag {tagname}
4) Delete and recreate the tag remotely
git push origin :{tagname} // deletes original remote tag
git push origin {tagname} // creates new remote tag
This is based on https://gist.github.com/739288 thanks to nickfloyd for it
@medusar
Copy link
Author

medusar commented Oct 14, 2016

when a new tag was created, new changes can not be committed to the tag, but if you do want to do this, you may need the scripts above

@medusar
Copy link
Author

medusar commented Oct 14, 2016

http://stackoverflow.com/questions/21459540/add-new-commit-in-the-existing-git-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment