GitHub: merge conflict when two people change the same page
The merge conflict does not mean a damaged repository. Git cannot choose between two changes of the same passage. The biggest risk is to replace the entire file with one version, which makes the work of the other person disappear.
How to Recognize Cause
Open pull request and check the list of conflict files. Determine which branch is the target and whether someone added another commits to it during your work. Save the last commit identifier before taking action.
Compare both files and the history of changes, not just the CONFLICT message. The conflict may affect several lines, but different sessions can also update dependent files at the same time, such as articles directory and site map.
Step by step solution
1. Create a separate branch based on the current main. Don't do a push force on the main and delete other people's commites.
2 . Get the latest target branch changes. Open conflicting files and view both variants between HEAD tags, = = = == and the name of the second branch.
3 . Merge only those fragments that are really meant to coexist. For example, keep a new list of guidebooks, and search and pagination match to this list instead of restoring the old file in its entirety.
4 . Remove conflict tags, run lint, control types and tests. Also check the actual subpages, because the correct syntactically merge can still lose the function.
5 . Do commit solutions, update pull request and only after positive tests connect it to main. Before merging, check again that the branch has not been changed again.
How to see if the problem is gone
The history of the project must contain both intended functionalities; the <<<<<<< or >>>>> tag cannot remain in the code. The repository scan should detect a zero number of such fragments.
Run the application and check the scenarios from both changes, e.g. a set of guides and search operation. The status itself 'mergeable' does not prove the correct behavior of the page.
What to do
Do not use automatic 'accept incoming' for the entire file if it contains independent fixes. You can remove content that cannot be reproduced from the current view.