Last Updated: October 06, 2018
·
55.54K
· ajduke

How to create branch from tag- Git

After finishing the certain features or after completing the milestone-

  • We usually tag that commit in Git
  • Push that tag in remote repo for others to view
  • Delete feature branch if any created
  • and Go home

Like following -

git tag v1.0
git branch -d my-milestone-1
git push origin v1.0

But what if, we found bug appearing in that committed and pushed code .

So, someone needs to start working from that point
i.e. from that tagged commit.

Its just easy you need to create the new branch out of that tag and start working on that branch.

Lets see how-

First of all , if we dont have tags in local git repository, lets fetch them all

git origin fetch

Now, we have all the tags from the remote repo.

Create the branch from tag, following is general syntax for it

git branch <new-branch-name> <tag-name>

For E.g.

git branch milestone-1-fixes v1.0

We have new branch, which is started from that tag i.e. from tagged commit

Check out the branch in working directory to start working on same-

git checkout <new-branch-name>

For .e.g.

git checkout milestone-1-fixes

Done!! Now start working this branch. Do your magic with Code and then

commit-> tag -> push to repo -> go home