Reputation: 153
I am new to this tag concepts. In main branch, i pulled the most recent commits with
git pull origin main
I pulled the remote tags with
git fetch --tags --force
Then, I created a tag locally
git tag -a v2.2 -m "some message"
the problem is, when i checked the tags in VScode, the tag v2.2 is having the commits of v2.1. I want only the commits made after v2.1 to be present in the new tag. How can i do that ?
Upvotes: 1
Views: 252
Reputation: 1324278
You would need to add and commit first on your branch, before adding a tag.
If you tag right after a pull, you would tag the last fetched commit, which might be the one already tagged v2.1.
Don't forget, a tag references a single Git object (here a commit).
That commit, in turn, has a reference to a history of past commits (including the v2.1 one).
- If I do "
git diff v2.1..v2.2
" its showing the older changes which I commited before creating tag v2.1 as new change
See "What are the differences between double-dot "..
" and triple-dot "...
" in Git diff commit ranges?"
git diff v2.1..v2.2
will show you what is in v2.2, and what is not in v2.2 compared to v2.1.
Check first if v2.1 commit is a direct descendant of v2.2 commit (ie, if they are on the same branch).
I made some commits (lets say 10 commits) in "Feature" branch , merged to "develop"(remote) via PR and then to "main" via PR(remote) from develop.
Now I need to create a tag (v2.2). So I pulled the main, created a tag pushed it to remote. when I checked the diff between v2.2 and v2.1, but there are like 20 commits.
I would recommend:
git fetch
git tag -a v2.2 -m "some message" origin/main
git push --tags
That way, you are sure to tag what is from the remote origin
you just fetched, rather than your local main
branch, which would include local commits of your own, not yet pushed.
The OP Hari Warshan clarifies in the comments:
I had some other commits which wasn't there in remote.
That is what caused the confusion.
Upvotes: 1