Force push
Rationale
Typically you will fetch the remote, merge your code, then push it back.
In some cases, the remote is destroyed (e.g. by a mistake) and a merge is not desirable.
In this case, you just want to discard any changes in the remote and let it mirror your local repo.
The commits of the collaborators will be gone, and they need to sync the local repo afterwards.
Use with caution.
Commands
git push -f
orgit push --force
Collaborators syncing local repo
When the collaborators fetch from the remote, their
origin/master
will be in sync with the remote. However, their local repo is ahead of theorigin/master
, with those deleted commits still there.They need to do a hard reset to sync with the
origin/master
.git reset --hard origin/master
Last updated