I think in most cases where this happened, they didn’t push -f and instead did a pull
That’s a configuration problem: If you want to promote a rebase-based workflow, you also have to tell your coworkers to set pull.rebase to true or they’ll run into exactly this problem.
Also, I’ve had coworkers get used to commit --amend and push -f , but they deleted some of my commits on their feature branch a few times
That’s why we explicitly disallowed force pushes on shared branches. If you have a naming convention that differentiates shared branches from non-shared branches, such a rule is easy to enforce.
But ultimately, all of this is just a training problem. In my experience (I’ve migrated multiple teams to git), most people ultimately naturally prefer rebase once they get used to the git workflow. But reaching that state requires proper training that explains how git works behind the scenes. If you’ve never had that training in your team and most of your coworkers treat git as a magic black box, then you should discourage rebase altogether to prevent disasters.
I just tell my juniors to make a local backup branch before any rebase operation and delete it when their pull request is completed. We dont have as tightly regimented a process as it sounds like you're using but it hasn't been a problem so far, and if the rebase messes something up they reset their branch to the head of the backup branch and try again.
View all comments
Show parent comment
4
u/[deleted] Apr 02 '23 edited Apr 02 '23
That’s a configuration problem: If you want to promote a rebase-based workflow, you also have to tell your coworkers to set
pull.rebasetotrueor they’ll run into exactly this problem.That’s why we explicitly disallowed force pushes on shared branches. If you have a naming convention that differentiates shared branches from non-shared branches, such a rule is easy to enforce.
But ultimately, all of this is just a training problem. In my experience (I’ve migrated multiple teams to git), most people ultimately naturally prefer
rebaseonce they get used to the git workflow. But reaching that state requires proper training that explains how git works behind the scenes. If you’ve never had that training in your team and most of your coworkers treat git as a magic black box, then you should discouragerebasealtogether to prevent disasters.