Hard reset a working copy to the remote branch
git reset local branch to origin | git pull fails because of local changes | discard all local changes git | your branch has diverged | git | reset | deploymentWarning, destructive. This command deletes, overwrites or changes data in a way that cannot easily be undone. Check every placeholder carefully and make a backup first.
git fetch origin && git reset --hard origin/mainFetches the current state from the remote origin and sets the current branch, the index and all tracked files exactly to it. Typically used on deployment servers when git pull fails because of local changes or diverging history. Untracked files such as uploads remain untouched.
Note: Local uncommitted changes are lost afterwards. Discarded local commits can still be rescued for a while via git reflog.
Also searched as
- git reset local branch to origin
- git pull fails because of local changes
- discard all local changes git
- your branch has diverged