git tag vs branch

Git Tags vs Branches

Git is a popular distributed version control system used by many developers as well as organizations. Among its numerous features, it allows you to create git branches and tags. But often, many get confused between the two. In this article, we will learn the difference between git tags vs branches and the difference between the two.


Git Tags vs Branches

Here are the key differences between git tags and branches.


Git Tags

Tags are a symbolic name given to a specific commit. They always point to the same object and do not change. You can have only 1 git tag with a given name in a git repository. You can have multiple tags for a single commit. Tags reside in refs/tags namespace and can point to tag objects.

Here is the command to create a tag in git.

$ git tag <tagname>

Here is the command to add description while creating tag.

$ git tag <tagname> -a

Here is the command to push tags to your git repository.

$ git push origin --tags


Git Branch

Git branch is a sequence of one or more commits to indicate a separate branch of development from the main master branch. You can have multiple branches in a git repository. You can always add more commits to a branch, which will not affect the other branches in your git repository. Branches reside in /refs/head namespace. The HEAD (current working branch) pointer must always point to a branch.

Here is the command to create git branch.

$ git branch <branchname>

Here is the command to switch to a branch

$ git checkout <branchname>

Here is the command to list all branches in git.

$ git branch -a

Here is the command to push a branch to remote git repository.

$ git push origin <branchname>

In this article, we have seen the key differences between git tag and git branch.

Also read:

How to Sleep Function in Python
How to Fix Access Denied Error in MySQL in Ubuntu
How to Remove NaN from List in Python
Delete All Files Except One in Linux
How to Mount Remote Directory or Filesystem in Linux

Leave a Reply

Your email address will not be published.