I just did a
git push -f
without including the branch I intended to push and git just blasted in everything to my repo. Fortunately we could piece together the old repo without to much trouble but it would be nice if I could change a setting in git to prevent -f all or make it so I have to do it explicitly.
Anyone aware of a setting I can change for this?
You can setup a pre-receive hook on the remote repo, that can prevent force push. You can also ensure that force push can only be done if explicitly specifying a particular branch.
You can also setup your local repository to change the default behaviour of the git push so that it will push only the current branch:
For example, to default to pushing only the current branch to origin use git config remote.origin.push HEAD. Any valid (like the ones in the examples below) can be configured as the default for git push origin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With