In this lesson, you will learn how to transition your project from a conflicted state back to a clean, functional state by staging your manual resolutions and completing the merge process.
Moving Beyond Conflict Markers
When you manually resolve a conflict, you edit your source files to remove the Git conflict markers (<<<<<<<, =======, >>>>>>>) and ensure the code logic is correct. However, Git does not know you are finished simply because the file looks correct. As far as Git is concerned, you are still in the middle of an "unmerged" state.
To move forward, you must explicitly tell Git that the conflicts have been addressed.
The Finalization Workflow
Finalizing a merge is a two-step process. First, you add the files you modified to the staging area. This signals to Git that the "conflict" status for those specific files is resolved.
# 1. Stage the files you have manually fixed
git add path/to/resolved_file.js
# 2. Complete the merge commit
git commit
When you run git commit without any arguments, Git will automatically open your default text editor with a pre-populated commit message describing the merge. You generally don’t need to change this message; you can simply save and close the file to finalize the operation.
Why the Commit Matters
It is important to remember that until you run that final git commit, your repository remains in a "merging" state. If you try to perform other operations—like switching branches or pulling new updates—Git will prevent you from doing so to protect the integrity of the merge. By committing the resolution, you are officially creating a new "merge commit" that ties the history of your feature branch into your main branch, successfully integrating the changes.
Once the commit is made, your working directory is clean, the conflict markers are gone, and your project is fully synchronized and ready for the next task.
Key Takeaway: After manually cleaning up conflict markers in your files, you must use git add to stage the resolutions and git commit to formally finalize the merge and restore your repository to a normal state.