Sometimes, especially if you work on your project from multiple computers, you will experience a merge conflict when you attempt to sync with your remote.
Merge conflicts are a totally normal part of source control management, and resolving them is quite simple.
-
Whether you are resolving the merge conflict on the GitHub desktop app or on the Remote (using the website), the process is quite simple.
-
First, examine the two versions of the file below. Notice that both have different changes on the same line. One was edited in Netbeans, and the other from the GitHub website.
-
Notice, there in an error in the GitHub Version,
java.io.Scannerdoes not exist. Additionally, we provided an output to the user on the Netbeans version that is missing from the GitHub version. -
When you open the file to resolve the conflicts in an editor, it will look something like this.
-
To resolve the conflict, examine an example conflict
<<<<<<< HEAD
import java.util.Scanner;
=======
import java.io.Scanner;
>>>>>>> origin/master
- The portion above the equals signs is the version currently on the desktop, the version below is currently located on the remote.
- The first question we should ask is "Why did I use two different imports? Which one is correct?"
java.util.Scanner;is the correct import statement, so we should delete the incorrect statement.
<<<<<<< HEAD
import java.util.Scanner;
=======
>>>>>>> origin/master
- Now, in order to indicate to git that the conflict is resolved by removing the labels.
import java.util.Scanner;





