What is a merge conflict and how do you resolve it?
A merge conflict happens when Git cannot join two changes automatically, mostly because two branches changed the same line of a file differently (or one deleted a file the other changed).
Git stops the merge and puts markers in the file:
<<<<<<< HEAD
Title: Welcome to Tutorials Class
=======
Title: Welcome to our shop
>>>>>>> feature
Steps to resolve:
- Run
git statusto see the files which are “both modified”. - Open each file, choose the final text, and delete the three marker lines.
- Stage the file with
git add file. - Finish with
git commit.
To cancel the merge, use git merge --abort. Full example: Git Merge Conflict.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |