When collaborating in teams with Git, someone else may do a “force push” on a feature branch, that conflicts with local revisions previously pulled.
Here are a few simple scenarios to resolve this situation quickly.
For simplicity, in this article we assume work in a Git branch
First, make a copy of the Git repo in case a mistake is made.
Erase local changes in
feat1 and match the remote Git repo.
git switch feat1 git pull --rebase
To preserve work in
git switch feat1 git fetch git reset origin/feat1 --soft
The work can be committed as usual after the reset.