Rebase : a discipline that keeps your git repository commits neat

Image for post
Image for post

If you look back your git commit history as the diagram below, do you prefer the left or the right side of the commit traces?

Image for post
Image for post

Obviously the left side of item looks neater. Is that achievable? For a small size of development team, I would say Yes. It requires some level of of planning as below.

  1. Partition the project into features that will involve distinct decouple codes as much as possible. Of course the based architecture of the app is crucial to determined if such partition is easily feasible or not.

If you are not sure what rebase is, refer to the below site.

The Caveat

There are caveats for point 1 and 2, where it can’t be fulfilled. This is especially true for huge complex projects across features, or major refactor of the base architecture work. This shouldn’t happen that frequent though… else I would think the base architecture in place is flawed.

But for item 3, lots of time is just a matter of discipline. If it becomes the habit of the team, things might not be perfect, but it definitely would be much neater.

Having said that, there are some caveat for rebase as below: -

  • When trying to rebase, there are numerous conflicts, that need to be resolved over and over again. This could be due to some major conflicts that happens at early of in the branch off. In this scenario, a merge might better than doing the rebase. Saving some time at the expense of neatness. Such scenario could be reduced having step 1 and 2 above handled well, and also a frequent rebase performed.

Discipline is the soul of an army. It makes small numbers formidable; procures success to the weak, and esteem to all. — George Washington

Written by

Passionate about learning, and sharing mobile development and others

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store