Make force push safer
You may use git exclusively through the cli, but, some editors (like vscode), it will automatically run git fetch
every 2 minutes in the background, and show you if there are new commits to pull down.
If you want safer force pushing, you'll need to disable auto-fetching inside your editor.
First, it's a good idea to force push through the gui, because it uses very explicit syntax:
vscode runs this under-the-hood:
git push --force-with-lease origin feature/foo:feature/foo
You can influence this call with the git config option push.useForceIfIncludes
:
[push] useForceIfIncludes = true
You can combine this with disabling auto-fetching in vscode:
"git.autofetch": false,
This would then cause force pushes through vscode's gui menu to fail unless you explicitly run git fetch
or git pull
or git pull --rebase
before hand.
- show the diff between your local branch and the remote branch
- show diff of log, allowing you to see which shas/commits will be obliterated, and what they will be replaced with
- tell you if force push is even necessary
- implement *even safer* checks