Git and GitHub Beginner Tutorial 7 - Git Tags - what, why, when and how

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello and welcome to this session on git tags today We will learn about tagging in git and we will also see a very basic step-by-step guide on how to create show publish and delete tags in Git Let us begin in Git or in any other version control system Tagging is a process, whereby we can Mark or create specific points in the history of our project or repository, and this is usually done to Mark some release points for Well your projects table and you want to mark it as release1.0 you can create a tag for that Apart from that you can also create tags whenever you want to Mark a historic point for your project or for your data So whenever you want to create a release point for a stable version of your repository or your project or whenever you want to create a historic data, which can be referenced at any point in future You can create tags Let us see a very basic step-by-step guide on how to create tags in git The very first step is you will check out the branch on which you want to create a tag And the command is git check out in the branch name For example, I want to check out my master Branch I am going to my terminal and if you are on Windows, you can go to your git bash and we have already covered this in our earlier sessions So first I will go to the location of my local directory So my local is my folder and I have come here and now I will say git Checkout master, and I'm already on my master branch Step two is now I will create a tag and give some tag name The command is get tagged in the tag name For example, I will create a tag by the name version 1.0 I will say get tag V 1.0and now I can say git tag to see the tag is already created So this is how I can create a tag I can also create an annotated tag by using the option -A So if I want to create an annotated tag, I will say get tagged -A the tag name -m and some message I will say this is a tag for release version 1.1 And now if I say get tagged I can see two tags are created now in our case version 1.0 is a lightweight Tag and version 1.1 is an annotated tag The difference is in an annotated tag You can give some message and it also will contain all the information about the tagger and it will be stored as a complete git object in git Repository So this is how you can create tags now, we will see how to display or show tag you can use git tag as I did all you can do git show and the tag name Let us do get show version 1.0 and it will show me the details of this particular tag You can also use wildcard characters using the -L option I will say git tag -l v1.* and it will display all the tags starting with V1. Let us go to the next step and how do you push tags to remote? Let me go to my GitHub remote And here let me go to this repository that I am using right now and you can see it has zero releases or zero tags because we have not pushed these tags to our remote how to do that The command is git push origin and the tag name I will say git push origin version 1.0 And this command should push my tag be 1.0 to my remote Let me go and refresh and check And Yes, you can see now It has created One release here You can also use git push origin --tags or git push --tags to push all the tags at once Let me do git push --tags This should push all my tags to my remote repository And now if I go and refresh my remote I am seeing now two release activated here So this is how you push the tags to remote if you want to delete the tags The command will be in get tag -d and the tag name or you can also use git tag --delete and the tag name Let me do git tag -d v1.0 It has deleted the tag 1.0 If I do a git tag now I only have be 1.1 I can also do git tag --delete v1.1 And if I do a git tag now, there are no tags in my local but the tags are still there on my remote repository So I have to delete from the remote as well to deleting from remote we can use the command git push origin -d and the tag name or --delete and the tag name i can Use git push origin -d v1.0 This should delete tag be 1.0 from my remote And I can go and verify this and yes, I just have one release left. I will say git push origin --delete be 1.1 This is another way of deleting the tags from my remote So now I should not have any releases or any tags And yes, there are zero releases on my remote So this is how you can delete tags You can also delete multiple tags from local or from remote using this command You can use the same command and give all the tag names that you want to delete Let us now See what exactly we have done I had checked out my master branch and whenever I do any changes I will commit So these circles with the number represent a commit I have Commit point one I again do some changes or additions in my project and I again do a Commit This is commit Point 2 and this is commit point 3 at commit three I think my repository stable or I want to take a backup or a historic point at this particular location So I will say git tag v1.0 and it will Create a tag V 1.0 And then I can push the tag to the remote server So this has created a historic point for this particular instance of my repository, but I will still continue to do the changes So I have done commit for I have done commit 5 and at this particular point I again want to create a tag so I can create a tag v1.1 Now every commit Point has a number and this is a checksum Let me just show you if I do a git log, you will see every commit has this 40 digit number This is called a checksum number and it is generated by a sha 1 algorithm And whenever there is a change and you will do a commit you will get a unique checksum number No, essentially this particular commit and v1.0 both refer to the same state of the repository And this is how committing and tagging works and in real life. You might have multiple branches You will check out merge and you will do tagging So the diagram may be a little complex, but this is essentially and exactly what will happen when you do commit and one when you do tagging in git how do you check out tags in git So there is no concept of checking out tag in git However, you can create a branch from a tag and then you can check out the branch For example, if you want to check out the tag version 1.0 You will say git checkout -v and give any branch name and then the tag name This will check out a branch and it will have the same state of the repository that you tagged at v1.0 Let us suppose you want to go back to some commit point and you want to create a tag for that particular Point how you can do that This is the command git tag tag name and the difference of the Commit and the difference of the commit Is this checksum number that we just talked about and you do not have to give the entire 40 digit number You can give a part of it For example, if I want to create a tag with this particular commit that I did on October 15, I can say- I can use this particular Checksum number or a part of this number and I can use this command git tag the tag name and the checksum number. So let me just show you I will say git tag v1.3 and this number and now you can see this tag is created I will also say gut push --tags and i will push this tag to my remote repository let me go to my remote and now i have 1 tag let me click here and you can see this version 1.3 is created which was done on october 15 so this is how you can go back and do tagging in your repository i hope all these concepts are very clear to you now i will meet you in the next section Thanks For Watching.
Info
Channel: Automation Step by Step
Views: 126,438
Rating: undefined out of 5
Keywords: git tags, git tagging, tags in git, tagging in git, what are tags, tags, tagging, create tags, show tags, push tags, delete tags, git checkout, lightweight tags, annotated tags, git tag tutorial, git beginner tutorial, learn git, git how to
Id: govmXpDGLpo
Channel Id: undefined
Length: 10min 41sec (641 seconds)
Published: Fri Dec 30 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.