Home > database >  Trying to clone repo, add a tag and push it back, the tag will appear but my code changes wont
Trying to clone repo, add a tag and push it back, the tag will appear but my code changes wont

Time:12-11

I have a repo with branch master and lots of tags. i would like to pull the code, add a new tag and push the code back to github. then see the code with the new tags and my changes. the result of what im doing now is just that i see the new tag on the code but the code itself is no different

git clone <repo url>
git tag -a 3.0.2 -m "testing"

(now im doing some code changes)
git add .
git commit -m "some changes"
git push origin 3.0.2

im getting output 
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 171 bytes | 171.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
To https://<repourl>....git
 * [new tag]         3.0.2 -> 3.0.2

and now i can see the new tag in the github repo but the code looks the same like the one i clone and does not have my changes in it

what am i missing?

CodePudding user response:

git tag, when used to create a new tag like this, does exactly that: it creates a new tag.

A tag name, in Git, simply selects some existing commit.1 Since the commit by definition already exists, there is no change in any code.

If you wish to have different code, you must make the different code (e.g., by changing some existing code) and then make a commit. You can then tag the new commit, if you wish—that's not really required, it's just a way to produce a human readable and understandable name for the new commit. The non-readable raw hash ID also selects that commit, and you can use that instead of the tag (but nobody wants to memorize some big ugly random-looking hash ID!).

You made the tag first, then you made some new commits. That's the wrong order!


1Technically, a tag can tag any of Git's four kinds of objects, but most people only tag commits anyway.

  • Related