Recovering from a forced push to a tracked repository

If a remote repository has been force updated (git push -f), the local repository's history must be rewritten to account for it (unless the master is incorrect, in which case a forced update may be the only corrective measure).

A reset with the --hard flag will

reset the index and working tree. Any changes to tracked files in the working tree since <commit> are discarded

A fetch is necessary first to ensure the remote changes are reflected in the local indexes.

To reset the local repository's HEAD to the remote's HEAD:

$ git fetch
$ git reset --hard origin/master