Sorry, been a while since I done that.
You have to be checked out to branch main.works, if your local branch has not diverged.
I.e. reverts changes in the worktree. Undoes any "git add".
IIRC Keeps you at the current commit, so if that diverged (if you have local commits that you need to drop) then "git pull" still will not be able to fast forward (but you could rebase)
git reset --hard origin/main
Will also reset your local branch main to the commit "origin/main" (from which you will be able to fast forward to any newly pulled commits on main).
This drops the local commits, if you have any on main.
If you are
not on main (works too, if you are on main), you can use "git switch"
git switch -f -C main origin/main
(and then git clean -fdx if you want to clean up)
The uppercase C is a forced action, and sort of includes a reset.
The -f will make sure it will ignore any other showstoppers
- Create a branch main at origin/main
- overwrite the old branch (reset the old branch to the new location if there was an old)
- checkout (switch) that new branch (update the files in the worktree)
The -f is only needed in rare cases, where git switch would complain. I can't recall what it forces on top of the -C.
(Maybe something like if a file exists, that needs to be created by the checkout)