Skip to main content
How to Create a Branch from a Tag and Tag from a Branch in git

Git tags are markers or references that point to specific points in the history of a Git repository. They are often used to label specific commits as significant, such as release points (e.g., version numbers like v1.0, v2.0, etc.) or to mark specific commits for easier reference.

 

Creating a Tag from a Feature Branch

  • Checkout the Feature Branch e.x, master:
    • git checkout master

 

  • Ensure Your Branch Is Up-to-Date:
    • git pull origin master

 

  • Create a Tag:
    • Using a Specific Commit
      • git tag -a v1.0 -m "Version 1.0 release" <commit_hash>
        • Replace v1.0 with your desired tag name
        • Replace <commit_hash> with the hash of the commit you want to tag
    • Using latest commit on the current branch
      • git tag -a v1.0 -m "Version 1.0 release"
        • Replace v1.0 with your desired tag name

 

  • Push the Tag to Remote:
    • git push origin v1.0

 

  • Listing all tags
    • git tag -l

 

 

Creating a Branch from a Tag :

  • Checkout the Feature Branch e.x, master:
    • git checkout master

 

  • Listing all tags and find the tag you want to create a feature branch from
    • git tag -l

 

  • Create a new branch from the defined tag
    • git checkout -b branch-name tag_name

 

  • Validate the current branch
    • git branch

 

 

Published on

Blog type