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 out-of-the-box thinker with strong interests and knowledge in technology and innovation.
dirtydozen.dev Previous post dirtydozen.dev – No unit tests
NET Core SDKs Next post Fix Missing NET Core SDKs

Leave a Reply

Your email address will not be published.