Reset Local Repo to Match Remote Repo Exactly
At any point, you may want to completely reset your local project so it matches the remote repo exactly (discarding any local changes, extra files, etc.).
Here are the safe ways depending on how “hard” a reset you need:
Option 1: Reset branch to remote (keeps untracked files)
git fetch --all
git reset --hard origin/main- Discards local commits
- Resets all tracked files to the remote state
- Leaves untracked files (stuff Git doesn’t know about) in your working directory
Option 2: Reset branch and also delete untracked files
git fetch --all
git reset --hard origin/main
git clean -fd- -f means force
- -d means removing untracked directories too
- After this, your working directory (local project repo) matches to the remote repo exactly.
Option 3: Really start fresh (nuke & re-clone)
cd ..
rm -rf your-project-folder
git clone https://github.com/your-username/your-repo.git
cd your-repo- Above is simplest and cleanest
- This guarantees no leftover files or configs
- Useful if you’ve had a lot of messy local changes
origin/main vs origin main
origin/main is a ref name (a branch), single argument.

