2

How do I tag all commits with a new tag?

I know how to tag a single commit but how can I do it on bulk, and the push the tags up to GitHub?

7
  • 2
    What do you mean by tagging all commits!? Commented Aug 3, 2013 at 12:24
  • @johannes Ok - so in my master branch I have around 50 commits. I have only recently been introduced to tagging in git/github. So I want to go back to the first commit and apply tag v1 so all 50 commits are tagged as v1 as I am about to begin v2. Also want those tags to be pushed up to github.com i will then make a v1 release in github too. jQuery use the tagging system. Commented Aug 3, 2013 at 12:25
  • thats not how you use tags.... use tags to mark releases, ie. tag the final commit of your v1 work as v1, and then start v2. Commented Aug 3, 2013 at 12:28
  • ok. so just place a tag on commit 50 (last commit of the version)? How do I push this up to github? See github.com/jquery/jquery/blob/2.0.2/.editorconfig Commented Aug 3, 2013 at 12:28
  • Do you want to continue developing on the v1 series (bug fixing or such?) then make it a branch (git branch v1 or such) and continue on master, if not you can tag your last v1 or first v2 commit to find it again, aside from that one typically tags as part of a release process Commented Aug 3, 2013 at 12:29

1 Answer 1

7

You cannot tag all commits with one tag. A tag can point to only one commit, so even if you run through all your history and tag them you'll face to problems:

  1. You'll need to use -f option to tag, because once you place a tag, a tag with the same name can only be forced
  2. After your script end, the tag will point to the last commit.

But, as I mentioned, it is possible. You can iterate through output of git log and place tags (with different names), or you can use libraries (JGit, for example). After tags are placed, do git push github --tags.

P.S. I think you are trying to do something bad. Tell us why do you need it?

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.