My coworker Calle (not in the picture) suggested in our guides that we
prefer the flag
--force to the
command. This option allows one to force push without the risk of
unintentionally overwriting someone else’s work. It will update remote
references only if it has the same value as the remote-tracking branch we have
locally. In other words, only if nobody has updated the branch upstream. If
there are new remote commits,
--force-with-lease will fail with a “stale info”
message, prompting us to fetch first.
[alias] pf = push --force-with-lease
I now always push with the
pf alias, which always gets my work merged with
upstream. Unless it could set the house on fire.