My ultimate safest solution to avoid accidentally overwritten other dev's commit goes like this, use 2 options at the same time. git config --global alias.pushf 'push --force-with-lease --force-if-includes'
[alias] pushf = push --force-with-lease --force-if-includes
Alternatively, specifying
--force-if-includes
as an ancillary option along with--force-with-lease[=<refname>]
(i.e., without saying what exact commit the ref on the remote side must be pointing at, or which refs on the remote side are being protected) at the time of "push" will verify if updates from the remote-tracking refs that may have been implicitly updated in the background are integrated locally before allowing a forced update.