Someone forced an update on my git repository, what do I do?
Forced update
Damn, someone used
git push --force
my repository (oh wait, it was me, from another computer). What do I do, now?
Simple, you want to discard your master
branch and make it point to the
last commit on origin/master
.
# make sure you are on the master branch
git checkout master
# make master point to the last commit on origin/master
git reset --hard origin/master
Of course, if you have ongoing changes you want to keep, git stash
them before.
Too late?
I know someone else pushed a forced update but I did a
git pull
anyway and now the 2 branches are merged, it’s ugly. Can I do something? Is it too late?
You can fix it. With the same solution:
# make sure you are on the master branch
git checkout master
# make master point to the last commit on origin/master
git reset --hard origin/master