Trusted answers to developer questions

How to create a branch in git from a specific commit id

Get the Learn to Code Starter Pack

Break into tech with the logic & computer science skills you’d learn in a bootcamp or university — at a fraction of the cost. Educative's hand-on curriculum is perfect for new learners hoping to launch a career.

As a programmer, each one of us has worked with branches in Git. Sometimes, you will want to go back to a commit that was done previously or you may want to create a branch from a previous commit.

You can do this using the following command:

git branch branch_name <commit_sha>

You can check the logs and copy the commit id at which you want to create the branch. An example of this is shown below:

git branch anjana d0a9ba

RELATED TAGS

git
Did you find this helpful?