git reset --hard origin/main

Category: Git - Advanced

git reset --hard origin/main

Reset your branch to match the remote

Throws away all local commits and working-tree changes on the current branch, pointing it at origin/main exactly. Every local-only commit is lost, so check git log first. Prefer it only when the local branch is known to be garbage.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.