FeaturesWP CloudPricingEE CLIContactMy Account

Features

Team Access & User Permissions

Server Setup & Management

Site Creation & Management

Deployments & Developer Tools

Firewall Protection

Speed & Caching

Backups & Recovery

Logs & Monitoring

Create WP Cloud Sites

All Features

Read Documentation

Install

Installation Guide

FAQ

Roadmap

Explore EE CLI

Resources

Commands

Handbook

Blog

Community

Forum

EasyExperts

Tutorials

Subscribe

Github

CLEAR

Start For Free

separator Tutorials separator Git separator Git – Resolve Merge Conflicts

Topics

On this page

Resolving merge conflicts

Find files with merge conflict

Resolve easy/obvious conflicts

For complex conflicts

Git – Resolve Merge Conflicts

Many time, when we do git push/pull or git merge, we end up with conflicts.

In most cases, solution to merge-conflict is as simple as discarding local changes or remote/other branch changes.

Following is useful in those cases…

Resolving merge conflicts

Find files with merge conflict

Change working directory to project folder.


			cd project-folder
		

Search for all conflicting files.


			grep -lr '<<<<<<<' .
		

Above will list all files which has marker special marker <<<<<<< in them.

Resolve easy/obvious conflicts

At this point you may review each files. If solution is to accept local/our version, run:


			git checkout --ours PATH/FILE
		

If solution is to accept remote/other-branch version, run:


			git checkout --theirs PATH/FILE
		

If you have multiple files and you want to accept local/our version, run:


			grep -lr '<<<<<<<' . | xargs git checkout --ours
		

If you have multiple files and you want to accept remote/other-branch version, run:


			grep -lr '<<<<<<<' . | xargs git checkout --theirs
		

For complex conflicts

For files that needs manual review/edit, use vim or any text editor to resolve differences.

Make sure you run git add FILENAME for files edited using vim.

Finally, review if all files are ready for commit using  git status

And run git commit -am "MSG" followed by optional git push

Git

PREVIOUS

First time Git setup

NEXT


Features

Useful Links

Product

Other Products

Subscribe for curated product updates, tips, and announcements.

"*" indicates required fields

Company

This field is for validation purposes and should be left unchanged.

Email*

SIGN ME UP

Δ


© rtCamp, since 2009. All rights reserved.

Powered by