Git tried to combine two branches and found both changed the same lines. It will not guess. It stops, marks the spot in your file, and waits for you to decide.
git status lists the files under "Unmerged paths". Only those need your attention.
Open the file. Keep your side, their side, or write a mix. Then delete the three marker lines.
git add the file, then git commit. Or run git merge --abort to go back to before the merge.
A conflict is not a broken repository. Nothing is lost, and git merge --abort puts everything back as it was before you started the merge.
you@laptop my-project % git merge feat Auto-merging f.txt CONFLICT (content): Merge conflict in f.txt Automatic merge failed; fix conflicts and then commit the result. you@laptop my-project % cat f.txt <<<<<<< HEAD main line ======= feature line >>>>>>> feat
Both branches changed the same line of f.txt. Between <<<<<<< HEAD and ======= is your current branch. Between ======= and >>>>>>> feat is the branch you are merging in. The steps are described in the GitHub Docs page on resolving conflicts on the command line.
git add FILE and git commit.git merge --abortBefore you commit, search the file for <<<<<<<, ======= and >>>>>>>. If any is left, the file is not finished. Run git status: when no "Unmerged paths" remain, run git commit. Run your project or tests once before you move on.
error: Your local changes to the following files would be overwritten by mergeCommit or stash firstSave your work with a commit, or park it with git stash, then merge again.fatal: not a git repository (or any of the parent directories): .gitYou are not inside a repositorySee the fix for this error.The top part, after <<<<<<< HEAD, is your current branch. The bottom part, before >>>>>>>, is the branch you are merging. ======= separates them. They are only markers, and you must delete them.
Run git merge --abort. It returns the repository to its state before the merge began.
Run git add on each fixed file, then git commit. Git offers a ready-made merge message.
No. Both versions are in the file until you delete one. Your earlier commits stay safe on their branches.