Create a Branch from a Commit

Published: March 8, 2020

Let's say you have committed some changes, but you want to continue from a previous commit without deleting your commits from the branch because you might want to go back.

  1. List recent commits to find the one you want to branch from. You can change the number 3 to how many commits you want to go back.
bash
git log -3
  1. Copy the commit hash (looks something like this: 5eb92c63c960036a9cb52aaa98b916ce9ca86979)
  2. Add your branch name and commit hash to the next step
bash
git checkout -b my-branch-name 5eb92c63c960036a9cb52aaa98b916ce9ca86979