Git flat history

Introduction #

Our main goal is to make the collaboration process enjoyable and seamless. We believe that flat history is one of the best ways to make git more effective. For ex. let’s say we have commits like the ones below; the merge will result as a combination of commits, whereas a rebase will add all the changes in feature branch starting from the last commit of the master branch: img

To avoid this situation we enforced flat history for the master, stage and dev branches: img

To get flat history in dev/stage/master branch we need to do rebase -i in custom branches before opening pull request on the github

When you do rebase a feature branch onto dev, move the base of the feature branch to the dev branch’s ending point. #

Merging takes the content of the feature branch and integrates it with the master branch. As a result, only the master branch is changed and the feature branch history remains the same. Merging will add a new commit to your history:

Commits should look like: img See more information here

When to rebase? When to Merge? #

In summary: use rebase for your branches. Never use rebase for dev/staging/production

If the feature branch you are getting changes from is shared with other developers, rebasing is not recommended because the rebasing process will create inconsistent repositories. For private (not shared) branches, rebasing makes a lot of sense.

If you want to see the history of a branch the same way it was built, you should merge. Merging preserves history whereas rebasing rewrites it. Rebasing is better when you want to streamline a complex history as you are able to change it via an interactive rebase. You can remove undesired commits, squash two or more commits into one, or edit the commit message.

Performing a rebase will present conflicts one commit at a time whereas a merge will present them all at once. It is much easier to handle conflicts but don’t forget that reverting a rebase is much more difficult than reverting a merge if there are one or more conflicts. You can find the details of a basic rebase process from git — Basic Rebase.

References #