MultiversX Tracker is Live!

What Git workflow do I need to use to be able to compare a PR branch before and after an author's force push?

Bitcoin Stack Exchange

Bitcoin News / Bitcoin Stack Exchange 180 Views

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>


Get BONUS $200 for FREE!

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