Resolve a conflict deliberately
git status
git diff
# edit the conflicted file and remove markers
git add app.conf
git commit- git status lists unmerged paths.
- The final commit records the chosen integrated state.
Resolve conflicting edits methodically by understanding base, ours and theirs instead of choosing a side blindly.
Git can automatically combine many changes. A conflict occurs when it cannot safely decide the resulting content, such as incompatible edits to the same lines.
<<<<<<<, ======= and >>>>>>> show competing sections in a conflicted file. Edit the file into the intended final form, remove markers, stage the resolution, then complete the merge.
If you started the wrong merge or need to reconsider, git merge --abort attempts to restore the pre-merge state. Resolve with evidence rather than automatically accepting ours or theirs.
git status
git diff
# edit the conflicted file and remove markers
git add app.conf
git commitGoal: Make main and a feature branch edit the same line, then resolve the merge.
mkdir -p ~/gnu-git-labs/module06 && cd ~/gnu-git-labs/module06
git init -b main
git config user.name "GNU Learner"
git config user.email "learner@example.invalid"
printf "mode=base\n" > app.conf
git add app.conf && git commit -m "Add base mode"git switch -c feature/mode
printf "mode=feature\n" > app.conf
git commit -am "Set feature mode"git switch main
printf "mode=main\n" > app.conf
git commit -am "Set main mode"git merge feature/mode || true
git status --short
git diffprintf "mode=integrated\n" > app.conf
git add app.conf
git commit -m "Resolve mode conflict"
git status --shortConflict resolution is a review task: the correct output depends on application intent, not on which branch is newer.
Open each answer only after you have tried to answer the question yourself.
Git cannot safely determine the combined content automatically.
Stage the resolved file with git add before completing the merge.
git merge --abort, when Git can restore the pre-merge state.