Create new branch from commit ID
You can create a new branch from the previous commits of any branch without reverting commits. Just one simple command!
Due to unwanted push/pull/merge, your branch often messes up with unwanted code. Some unnecessary and buggy commit lines up in your branch's commit history.
In this case, you wish to create a new branch from the last correct commit.
The naive approach is to hard reset the branch to specific commit, then create a new branch. ๐
But hold on... You can accomplish that without the resetting stuff. ๐
Here are the steps :
Checkout to the branch you need to create a new branch from.
Run
git log
: Get the ID of the commit from which you want to create a new branch.Execute
git checkout -b <branch_name> <commit_id>
And there you go... ๐
Now you have created a new branch based on the commit_id that was entered in the command.