Handling Merge Conflicts

In some cases, incoming changes can create a merge conflict. To resolve this conflict, Bit will use Git to try and automatically resolve it. When this is not possible, Bit will allow you to manually resolve the conflict in your code.

$ bit import

error: merge conflict occurred while importing the component geekrajat.stylesheetget/components/header. conflict version(s): 1.0.2

to resolve it and merge your local and remote changes, please do the following:

1) bit untag geekrajat.stylesheetget/components/header 1.0.2

2) bit import

3) bit checkout 1.0.2 geekrajat.stylesheetget/components/header

Once you run the bit checkout command as directed above, your merge conflict should be resolved. But there are still some chances of that not happening and you might get a prompt as shown below:

bit checkout 1.0.2 geekrajat.stylesheetget/components/header

automatic merge has failed for component geekrajat.stylesheetget/components/header.

please use "--manual" to manually merge changes or use "--theirs / --ours" to choose one of the conflicted versions

Here, Bit is asking you to decide how to resolve the conflict using one of three options:

--theirs - the remote version overrides the local modifications.

- the remote version overrides the local modifications. --ours - the local implementation overrides the remote changes.

- the local implementation overrides the remote changes. --manual - resolve the conflict manually.

The first two options are pretty straight forward. So, let’s look at how you can resolve the conflict manually by adding the --manual flag to the bit checkout command.

$ bit checkout 1.0.2 geekrajat.stylesheetget/components/header --manual



successfully run npm install at ...



successfully switched geekrajat.stylesheetget/components/header to version 1.0.2



updated src/components/header.spec.js

updated src/components/index.js

CONFLICT src/components/index.js automatic merge failed. please fix conflicts manually and then tag the results.

Resolve the conflicts within the specified file, Bit will open your merge tool and present you with the conflicted files(s) so you can resolve the conflict. Once it’s resolved, run bit status and bit tag to see that the changes have been merged (component is modified).

$ bit status

modified components

(use "bit tag --all [version]" to lock a version with all your changes)



> components/header ... ok

Now you can simply bit tag the component with the new version, and if needed export it to the remote Scope.