If you want to create a new branch from an older commit (not the latest one), here’s how:

✅ Steps:

Find the commit hash:

git log --oneline

Example output:

e3a1b55 Fix security issue
6f24a1d Add README
34d2a5c Initial commit

Create a branch from that commit:

git checkout -b my-old-branch e3a1b55

Note:

  • Replace my-old-branch with your desired branch name.
  • Replace e3a1b55 with the actual commit hash.

Push the new branch (optional):

git push origin my-old-branch

🔄 If you’re already on another branch and don’t want to switch:

You can also do this without switching branches:

git branch my-old-branch e3a1b55

Then push:

git push origin my-old-branch