Git is like a blockchain: it only keeps the "best-commit-chain". A git push -f
"reorgs" the prior chain of commits to a new "best chain".
If you checked out the PR before the force-push, your local git repository retains a copy of the commits from before the force-push. You can then use git fetch
and git range-diff <branch> <upstream/branch>
to compare the state prior and posterior of the force-push. If you have already checked out the updated branch after the force-push, your local repository still retains a copy of the prior commits (even if it doesn't show up in git log
) and you can compare by calling git range-diff <old-commit-hash> <branch>
. If you don't remember the old stale commit-chain-tip, you can look it up via git reflog
.
Similarly to a Bitcoin node either having seen an extinct chain-tip when it was relevant or there being no (easy) way to get it, you cannot easily get an overwritten commit unless you created a local copy of the upstream branch before the force-push since overwritten commits are discarded by GitHub. In that case, just start reviewing from scratch.
TIL that GitHub meanwhile apparently does keep old commits around for a while. So, if you're lucky and it hasn't been cleaned up yet, you may be able to retrieve the "stale commit-chain-tip" via: git fetch upstream <commit-hash>
You can get bonuses upto $100 FREE BONUS when you:
π° Install these recommended apps:
π² SocialGood - 100% Crypto Back on Everyday Shopping
π² xPortal - The DeFi For The Next Billion
π² CryptoTab Browser - Lightweight, fast, and ready to mine!
π° Register on these recommended exchanges:
π‘ Binanceπ‘ Bitfinexπ‘ Bitmartπ‘ Bittrexπ‘ Bitget
π‘ CoinExπ‘ Crypto.comπ‘ Gate.ioπ‘ Huobiπ‘ Kucoin.
Comments