Fed up with Git conflicts😤?: Rebase regularly and chill!

Maulik - Nov 5 '20 - - Dev Community

Git is a blessing, isn't it?

Absolutely yes, if used properly.

The general workflow that we follow in the project development is like
Alt Text

If you have observed the above flowchart, there is a red line drawn from the master branch to the merge commit and that is intentional.

Most of the time, many developers work on the same project and on different issues, and while we work, the master branch could have been updated with other's change and the master branch could have new commits. So let's update the diagram.
Alt Text

OK, updated the diagram. But what is the issue?
The issue is, there are possibilities of getting conflicts and we have to resolve either by merging the master branch to your branch or rebasing your branch with the master.

Now let's get this straight why I choose to rebase over merge

No extra merge commit
Master's history remain clean and linear

So when we merge master to our branch, we need to resolve the conflicts, and then it adds a new merge commit.

While in rebasing our branch is first updated with master and then our commits will be applied one by one.
Alt Text

If you are working on a complex task, you might need more time and the master branch will not wait for you, so I suggest to rebase your branch regularly(daily) and if there are conflicts resolve it, Otherwise at creating a pull-request or merge-request of a big task, conflicts may haunt you.

. . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player