How git pull --rebase can silently delete your commit and how to recover it
A common Git workflow hazard occurs when a teammate force-pushes to a shared branch, overwriting commits that others have already pushed. Running git pull --rebase after such a force-push can silently drop your commit, with all status indicators appearing normal. The lost commit is recoverable using the branch's reflog, which logs every state the branch has held locally, allowing a git reset --hard to restore it. Once recovered, the divergence between local and remote branches must be resolved properly before pushing again. The root cause lies in how git pull uses the --fork-point option during rebase, which can exclude commits rewritten by a force-push from the set of changes to replay.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in