Should I use rebase in GIT ?


When working on a long term project you want a clean history. Now we must establish what exactly means clean and history. People can, and probably should, rebase their own work. That’s a cleanup. But never other peoples work. That’s a destroy history.


The history part is easy. You must never ever destroy other peoples history. You must not rebase commits other people did. Basically, if it is not yours you can’t rebase it, because it’s not yours. It is very important that once you’ve published your history in some public repository, other people may be using it, and so now it’s clearly not your private history any more.


The clean part is a bit more subjective, although the basic rule is pretty obvious and easy: keep your own history readable! Some crazy people do this by just working things out in their head first, and not making mistakes.  For the rest of us, we use rebase  to clean up our messy commits. Rebase is not wrong. But it’s right only if it is used on your own private git tree. It may also be worth noting that excessive git rebase will not make things any cleaner. If you do too many rebases, it will just mean that all your code is of dubious value. So by all means rebase your own work, but use some judgement in it.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s