Life's random bits By b1thunt3r (aka Ishan Jain)…
Move un-pushed commits to a new branch

Move un-pushed commits to a new branch

Ishan jain
Sometimes you just forget (to create a new branch).

Scenario

You by mistake made 3 commits in main branch, instead of newFeatureBranch

Fix

Create a new branch on main

git branch newFeatureBranch main

Make sure main is checked out

git checkout main

Reset main back by 3 commits

git reset --hard HEAD~3

Note: You will loose any uncommitted work, stash it first!