Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch between the tags in Git

Tags:

git

I am new to git. And I am facing problems while moving between the tags. I want to switch between the tags. Like if I have two versions. For example. version 1.0 version 2.0 so I want to move from version 2.0 to version 1.0 in Git.

like image 727
KhanUstaad Avatar asked Nov 05 '13 14:11

KhanUstaad


People also ask

How do I checkout to new tag?

In order to checkout the latest Git tag, first update your repository by fetching the remote tags available. As you can see, you retrieve multiple tags from your remote repository. Then, retrieve the latest tag available by using the “git describe” command.

How do you switch between branches in git?

You can use the git switch - command to undo any changes you make and return to your previous branch. If you instead want to keep your changes and continue from here, you can use git switch -c <new-branch-name> to create a new branch from this point.

Can you have multiple tags in git?

To push multiple tags simultaneously pass the --tags option to git push command. When another user clones or pulls a repo they will receive the new tags.

Can we move tag in git?

This process is just like sharing remote branches — you can run git push origin <tagname> . If you have a lot of tags that you want to push up at once, you can also use the --tags option to the git push command. This will transfer all of your tags to the remote server that are not already there.


2 Answers

In git, a tag is given a name, which in git terminology is its reference. A tag in reality is more like an alias to a specific commit id (which is also a reference).

See http://git-scm.com/book/en/Git-Internals-Git-References

So to switch between tags you would use the same technique that you would use to switch between other references such as branches or commits... git checkout <tagname>.

like image 138
whaley Avatar answered Oct 12 '22 04:10

whaley


You are probably looking for:

git checkout tag

git checkout can be used to checkout any commit and after that it can be used with a branch name to go back to a named branch.

like image 21
Rahul Tripathi Avatar answered Oct 12 '22 03:10

Rahul Tripathi