Git is one of the most popular system to control version. Developers have history of their codes. Git can also merge and rewrite repository. So, developers can share one another, codes in a project by pulling it and comitting it. There are several commands that can be used with git. One of it is rebase command. Here, we want to show why rebase command return a ‘refusing to merge unrelated history.’
There are several options to overcome error message like that. However, to omit an error message actually is not a wise choice. It is because an error message is returned when something wrong happens with the code development and history. We could use option
--allow-unrelated-histories. However, it is the last option. The result is, the message disappear and the job could be finished. So, we need to investigate what is the matter with the code and why it is refused and how to fix history that is unrelated.
Check The Commit History of The Code
When we are working as a team, many developers work together. Every person doing pull command. When a developer is comitting new changes, everybody else should re-pull the new version of the code. From there, the development process can be continued. When a developer is developing the code from the initial pulling, where the newest version has been comitted, then this is the beginning of refusing unrelated history.
When creating a repository together, developers want to make changes on their works based on what everybody else has been done. When the feature has change, the request is being refused. This can not be overcome by omitting the message and then forcing to merge.
It is good not to rebase public history
That is because the history will vanish and can not be tracked. In a big development with thousands of code, it will be difficult to track when there is a bug. Working in a team means good cooperation. A team works for a company means the goal of the company is the goal of every person in the team.
When it is going to do, try with rebase interactive
Interactive rebase is different with standard rebase. The standard one will automatically comitting to its branch and become the head of the branch. If we are working on a function that is called from another function created by other developers, then, this will cause a bug.
To try this interactive rebase, simply add
--interactive option within rebase command.
Rebase is the last option in development process. When it has to be done, try with interactive option of the rebase command.