How to Create a Tag in a GitHub Repository?
Last Updated :
03 Jun, 2024
Tags are one of the important parts of Git and GitHub. We can see in the case of open source projects that the release of a particular version is attached with a tag. Tags are used to memorize a specific moment in history. Even after making multiple changes to the code, we can get back to the particular state of code if it is tagged.
We can create a tag in github repository with the below approaches:
Creating a Tag in GitHub Repository
Step-1: Go to the GitHub repository in which you want to make changes
GitHub RepositoryStep-2: Go to the Releases section and click on "Create a new release"
Create A New ReleaseStep-3: Click on the dropdown in "Choose a tag" and add the desired tag
Choose a tagStep-4: Choose the branch whose code will be taken for adding a tag
.webp)
Step-5: Give "Release title" of your choice and add any description if you want
.webp)
Step-6: Click on the "Publish release" button present at the bottom to publish that tag
.webp)
Step-7: Now on the project's repository page, we can see that tag under the "Tags" section
How to Create a Tag in a GitHub Repository?Creating tag with Git
We can also create tags on our GitHub repository using git commands. Now for that we will clone the repository then add tags to that and push that tag to the actual GitHub repository. So we will take the following steps to add tag to our repository-
Step-1: Clone that repository
For that, we will go to the code section and copy the repository URL
.webp)
After that, we will use following command to clone the repository
git clone {Link of Repository}
.webp)
Step-2: Use following command to get into the cloned repository
cd {cloned repository name}
.webp)
Step-3: Use the following command to get details of all the previous commits of that repository
git log
.webp)
Step-4: Choose the commit on which we want to apply tag. After choosing, copy the Hash of that commit.
.webp)
Step-5: After that use following command to add the tag
git tag -a {name of tag} {Hash of commit}
.webp)
Step-6: Now we will get Vim Editor to write a tag message. So after writing tag message we will press ctrl+c and write the following to save that message-
:wq
.webp)
Step-7: After that push the tag to the original GitHub repository by following command
git push origin {name of tag}
.webp)
Step-8: Now we can see that tag in the "Tags" section of that GitHub repository
How to Create a Tag in a GitHub Repository?- It is used to mark any release version
- It helps to go to any previously made commit
- It helps to mark specific changes in the project
- It helps to provide documentation for changes
- It helps to do automation in CI/CD
Similar Reads
How to Show All the Branches in a GitHub Repository?
In this article, we'll understand the concept of branches in Git and learn how to show them using different methods. Git, a version control system, is designed to track changes in software development projects. Additionally, GitHub serves as a platform to host these projects online and facilitates c
2 min read
How to Add Code on GitHub Repository?
GitHub is a powerful platform for hosting and sharing code. Whether youâre working on a solo project or collaborating with others, adding code to a GitHub repository is essential. Hereâs a step-by-step guide on how to add your code to a GitHub repository. Steps to Add Code on GitHub RepositoryStep 1
2 min read
How to Fork a GitHub Repository?
GitHub is a great application that helps you manage your Git repositories. Forking a GitHub repository is a common practice that allows you to create your own copy of a repository hosted on GitHub. In this article, we will learn more about Git-Fork and its uses. Table of Content What is GitHub Repos
3 min read
How To Create a Pull Request in GitHub?
Pull requests are an important part of collaborative software development on GitHub. They allow developers to propose changes, review code, and discuss improvements before integrating new code into a project. This guide will walk you through the process of creating a pull request in GitHub, ensuring
3 min read
How to Delete a Remote Tag in Git?
Git tags are important for marking specific points in your repository's history, often used for releases. However, there may come a time when you need to delete a remote tag. Hereâs a simple guide to help you understand how to do this. Table of Content What is a Git Tag?Why Delete a Remote Tag?Steps
2 min read
Creating Repository in GitHub
In this article, we will learn how to publish or upload projects to our GitHub account. This article will give you very detailed information about what is GitHub and how to set up a GitHub account. We will cover a brief introduction to GitHub and then we will step by step about How to create and man
3 min read
How to Create a Project in GitLab?
A popular web-based tool for the DevOps lifecycle, GitLab offers a Git repository manager. It integrates CI/CD pipelines, version control, and collaboration tools, making it a powerful tool for developers and companies. Creating a project is one of the first things you do while using GitLab. This ar
3 min read
How To Rename A Repository on GitHub?
Renaming a repository on GitHub is a simple task that might be necessary for several reasons: action may include project renaming, consolidation of repositories, improper naming conventions or, in general, redundancy and clarity. In this detailed guide, each of the steps involved in renaming a repos
6 min read
Pushing Changes to a Git Repository
Git allows developers to manage code changes collaboratively and efficiently. One of the fundamental operations in Git is pushing changes to a remote repository. Pushing changes ensures that your local commits are sent to the remote repository, making them accessible to other team members. This arti
6 min read
How to Add an Empty Directory to a Git Repository?
Adding an empty directory to a Git repository can be a challenging task, as Git doesn't track empty directories by default. However, it is essential to keep track of empty directories in a repository, especially if you are working in a team or if you want to maintain the directory structure of your
3 min read