Dunno Dunno - 4 months ago 64
Git Question

What happens if I rebase after pushing?

I always hear that it's something scary and something I should never do. For example, here's how the pull dialog looks like in SourceTree:

enter image description here

So I'm curious, what would happen and how bad would it be if I had pushed changes, then rebased and pushed them again? And how to fix the repository if I'd break it this way?


Nothing would happen, but your next push would be not accepted.

Unless you would force push. This would not break remote repository also, so it is also not that bad.

Things go bad when you have more people using this repo. Rewriting history can cause a bit of chaos for others who will pull new changes from remote. Especially if they do not have good knowledge of git. There can be different things that might happen for person pulling rewritten remote branch depending on state of their local repository.

So if someone would work on feature X and you changed the code on which he based his changes, he might get at least upset to downright angry depending on how much of his work you made obsolete.