Reset Git Branch Commits

Reset Git Branch Commits

Use this to set your Git branch to the "Initial commit" stage.

# checkout to temp_branch
git checkout --orphan temp_branch

# add all files
git add -A

# commit
git commit -am "Initial commit"

# delete old main branch
git branch -D main

# rename temp_branch to main
git branch -m main

# force push main 
git push -f origin main
Marcin Narloch

Marcin Narloch

Creative and pragmatic technology architect and game developer with decades of experience across enterprise cloud architecture, software engineering, innovation and digital transformation.
dirtydozen Previous post dirtydozen – No unit tests
NET Core SDKs Next post Fix Missing NET Core SDKs