Hacker News new | ask | show | jobs
by dilap 3357 days ago
Here's one: Use:

    git push --force-with-lease
Instead of

    git push -f
(Obviously ideally you'd never do either, but sometimes life happens.)

The advantage of the former over the latter is that it won't push if you haven't already seen the ref you're overwriting. It avoids the race condition of accidentally "push -f"ing over a commit you haven't seen.

(Why this isn't the default, I have no idea.)

1 comments

Yes, force-with-lease is really useful. I set it up as an alias of git fpush, and have never used push --force since.