DEV Community

Eelco Verbrugge
Eelco Verbrugge

Posted on • Updated on

Solve merge conflicts with PHPStorm

Once in a while a merge conflict popups. This happens when you've created your branch and in the meantime your colleague pushed changes just before you did on the same line. Git (or your colleague) will let you know if it can be solved automatically and if not, it's up to you how to fix it.

How to fix merge conflicts with PHPStorm?

1. Checkout the branch where you want to merge to. For example the master branch.

PHPStorm->Git->Branches...->master->checkout

2. Pull the latest changes to your local machine from master

PHPStorm->Git->Pull...->Pull

3. Checkout your_feature_branch where you've made your changes

PHPStorm->Git->Branches...->your_feature_branch->checkout

4. Also pull the latest changes to your local machine from your branch, just to be sure

PHPStorm->Git->Pull...->Pull

5. Merge master into your_feature_branch

PHPStorm->Git->Merge...->master

6. Resolve Conflicts

PHPStorm will automatically open this Conflict window if there is a conflict detected:

alt text

Choose Merge.

7. Accept or refuse solutions on the right or left.

alt text

Apply if done.

7. Git commit your changes

PHPStorm will automatically commit these changes if you Apply. Git will generate a comment for your commit such as "Merge branch 'development' into your_feature_branche"

8. Git push and celebrate life!

PHPStorm->Git->Push...

Thats all folks~

Source:
jetbrains.com

Top comments (0)