Hacker News new | ask | show | jobs
by elmigranto 3599 days ago
> If you screw up a rebase, the history is re-written…

https://git-scm.com/docs/git-reflog

> …or force-pushed by accident

Well, you could nuke git folder "by accident" as well :) Jokes aside, don't force-push to "other's" branches).

1 comments

If you really feel like you do have to force-push to someone else's branch, please use

    git push --force-with-lease origin/other_branch
so you at least won't trash any commits your collaborator pushed after you last fetched their branch. git will see that your origin/other_branch doesn't match origin's other_branch, and will bail out so you can pull the changes and decide how to incorporate them.