Git/C2/Tagging-in-Git/English

From Script | Spoken-Tutorial
Jump to: navigation, search

Title of script: Tagging in Git

Author: Priya K

Keywords: Video tutorial, tagging, annotated tag, lightweight tag


Visual cue
Narration
Slide 1: Welcome to the spoken tutorial on Tagging in Git.
lide 2: In this tutorial, we will learn about
  • Tagging and
  • Types of tagging
Slide 3:


For this tutorial, I am using
  • Ubuntu Linux 14.04
  • Git 2.3.2 and
  • gedit Text Editor

You can use any editor of your choice.

Slide 4: To follow this tutorial
  • You must have knowledge of running Linux commands on Terminal.
  • If not, for relevant Linux tutorials, please visit our website.
Let us learn about tagging.
Slide 5


  • Tagging is used to mark a commit stage as important.
  • We can tag a commit, like a bookmark, for future references.
  • Typically, this is used to mark release point of a project such as v1.0.
Slide 6


There are two types of tags:
  • Lightweight tag and
  • Annotated tag
First I will demonstrate how to create a lightweight tag.
Press Ctrl+Alt+T to open the terminal Let us go to our Git repository mywebpage which we created earlier.
Type cd mywebpage and press Enter Switch to the terminal and type:


cd space mywebpage and press Enter.

I will continue to use html files for demonstration.


You may use any file type of your choice.

Type git log --oneline Let’s check the Git log by typing

git space log space hyphen hyphen oneline


and press Enter.

Highlight the commits Currently, we have three commits in our repository namely "Added colors, Added history.html and Initial commit".
Highlight “Added colors


Now I will create a lightweight tag in the latest commit “Added colors”.


When we create a tag, by default, it will be created in the latest commit.

Type git tag v1.1 and press Enter Type git space tag space v1.1 and press Enter.
Highlight v1.1 Here I will give v1.1 as the tag name. You can give any name of your choice.
Type git tag and press Enter You can see the tag by typing git space tag and press Enter.


Now we have only one tag in our repository.

<<PAUSE>>

Next we will learn how to create an annotated tag.
First I will make some modifications in the file mypage.html for demonstration purpose.
Type gedit mypage.html ampersand and press Enter


Add lines in the file

Type gedit space mypage.html space ampersand and press Enter.


Let us add some lines in the file.

Save and close the file Then save and close the file.
Let’s commit our work at this point.
Type git commit -am “Added content in mypage.html” and press Enter Type git space commit space hyphen a m space

within double quotes “Added content in mypage.html


and press Enter.

Let us assume that this particular stage is very important to the project.


So we have to create a tag at this commit point.

Type git tag -a v1.2 -m “My Version 1.2” and press Enter


Highlight -m “Version 1.2”

Here we will create an annotated tag.


Type git space tag space hyphen a space v1.2 space hyphen m space within double quotes “My Version 1.2” and press Enter.


Using -m flag, you can give any tag message of your choice.


Here the tag message is optional.

Type git tag and press Enter


To see the tag list, type git space tag and press Enter.


Now we have two tags.

Highlight v1.1

Highlight v1.2

Here v1.1 is the lightweight tag and v1.2 is the annotated tag.


How do we differentiate between the tags?

We can see the difference between the two tags by using git show command.
Type git show v1.1 and press Enter Type git space show space v1.1 and press Enter.
Highlight commit details and file changes Here we can see the complete details of the lightweight tag v1.1.


It simply shows the commit details and the file changes.

Type git show v1.2 and press Enter Next, we will see the details of the annotated tag v1.2.


Type git space show space v1.2 and press Enter.

Highlight tag v1.2

Highlight Tagger and Date

Highlight date and time

Highlight Version 1.2

Highlight commit details

Highlight file changes

Here we can see the
  • tag name
  • tagger details
  • date the commit was tagged
  • tag message
  • commit details and
  • file changes.
Annotated tag is always recommended when you work collaboratively.


<<PAUSE>>

Let us now learn how to mark a tag in our old commits.
Type git log --oneline and press Enter First, we will check the Git log by typing

git space log space hyphen hyphen oneline


and press Enter.

Type git tag -a v1.0 hash -m “My Version 1.0” and press Enter Now for instance, I want to create a tag in my second commit Added history.html


Type git space tag space hyphen a space v1.0 space.


Then copy and paste the commit hash of the “Added history.html” space.


Type hyphen m space within double quotes “My Version 1.0” and press Enter.

Type git tag and press Enter We will be able to see the tag which we created now, by typing git space tag and press Enter.
Highlight v1.0 You can see the tag v1.0 is created here.
Next we will learn how to see the tags along with the Git log.
Type git log --oneline --decorate and press Enter Type git space log space hyphen hyphen oneline space hyphen hyphen decorate and press Enter.
You can see the Git log along with the tag names.


<<PAUSE>>

Now, we will learn to delete an unwanted tag.
Highlight v1.1


Type git tag -d v1.1 and press Enter


Highlight “Deleted tag 'v1.1'”

Highlight hash

Say, I want to delete the tag v1.1.


Type git space tag space hyphen d space v1.1 and press Enter.


It shows the message “Deleted tag 'v1.1'” and its commit hash.

Type git tag and press Enter We will check whether the tag is deleted or not.


Type git space tag and press Enter.


Now, we can't see the tag v1.1 as it has been deleted successfully.


<<PAUSE>>

With this, we come to the end of this tutorial.
Slide 7:


Let us summarize.

In this tutorial, we have learnt about

  • Tagging and
  • Types of tagging
Slide 8:


As an assignment
  • Create a lightweight tag and an annotated tag and
  • Understand the difference between both the tags
Slide 9:

Acknowledgement

The video at the following link summarises the Spoken Tutorial project.


Please download and watch it.

Slide 10:

Acknowledgement

The Spoken Tutorial Project Team conducts workshops and gives certificates to those who pass online tests.


For more details, please write to us.

Slide 11:

Acknowledgement


Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.


More information on this Mission is available at the following link.

This is Priya from IIT Bombay. Thanks for joining.

Contributors and Content Editors

Nancyvarkey, Priyacst