World map

 

BM: Baca dalam Bahasa Melayu

World 11: Rescue Center

Merge panic

You will learn: how to back out of a scary merge, calmly.

The problem

git merge title: Auto-merging index.html. CONFLICT (content): Merge conflict in index.html. Automatic merge failed. Terminal output: $ git merge title Auto-merging index.html CONFLICT (content): Merge conflict in index.html Automatic merge failed; fix conflicts and then commit the result.

CONFLICT! Scary words fill your screen. Your heart races. Breathe: nothing is lost. This happens to everyone. Here’s the safe way out.

Try it

git status always tells you where you are. Find the exit.

Tap the line that shows the way back.

~/diary $ git merge title~/diary $ git status

0 of 1 found

Try it

Cancel the merge. Go back to how things were.

6d3a9b1a8feb63270a76e887fcc8b48cc00

Predict

After git merge --abort, where is your work?

Pick one answer.

Check

Fix it now, or back out? Sort each moment.

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now back out of a scary merge, calmly.

      Go deeper (optional)

      The merge worked, but you regret it? Not pushed: git reset --hard ORIG_HEAD jumps back to just before it. Careful, that wipes uncommitted changes. Already pushed: git revert -m 1 HEAD makes an undo commit and keeps main’s side. Fixing conflicts step by step is in World 3.