Let's think about it this way for a second
When working with a team, merge conflicts tend to happen when two people edit the same file. In this section, we'll edit README.md directly on GitHub, and also edit README.md locally, deliberately creating a conflict and practicing how to resolve it. We'll also learn how to fix a mistaken commit with git reset, and how to wrap the project up with a final push.
Let's build it for real
Edit the README.md file directly through GitHub's web interface and commit it. Then, in your local repository, edit a different line of README.md and commit that too. When you run git pull, you'll get a conflict — open up the conflict markers, decide which version to keep, and resolve it. Next, create a commit called 'typo commit' just as a test, and undo it with git reset --soft HEAD~1. Finally, double-check your .gitignore and wrap up the project with a final git push.
Code Example
# Step 1: local မှာ README.md ကို ပြင်ပြီး commit လုပ်ပါ (GitHub ပေါ်ကလည်း တစ်ပြိုင်နက်တည်း ပြင်ထားသည်ဟု ယူဆပါ)
git add README.md
git commit -m "Update README with contact info"
# Step 2: pull လုပ်တဲ့အခါ conflict ဖြစ်လာမည်
git pull origin main
# CONFLICT (content): Merge conflict in README.md
# Step 3: README.md ကိုဖွင့်ကြည့်ပါ
# <<<<<<< HEAD
# (your local changes)
# =======
# (GitHub's changes)
# >>>>>>> origin/main
# -> လိုချင်သော content ကို ရွေးပြီး markers များကို ဖျက်ပါ
git add README.md
git commit -m "Resolve merge conflict in README"
# Step 4: မှားယွင်းသွားသော commit တစ်ခုကို reset ဖြင့် undo
git commit -m "typo commit" --allow-empty
git reset --soft HEAD~1
# Step 5: final push
git push origin mainAfter resolving the conflict, GitHub shows a clean commit history and the correct README.md content, and the whole project repository is fully pushed.Try it in 5 minutes
Edit index.html from both the local side and the GitHub web editor at the same time, create another conflict, and practice resolving it (5 minutes).
A quick word of caution
git reset --hard can permanently delete uncommitted changes in your working directory too, so always check with git status first and only run it once you're sure.