AI Hints
Home›Git & GitHub Tutorial›Fixing Conflicts
Git & GitHub · Lesson 49 of 144

Calm Merges

Abort, and avoid conflicts.

⏱ 2 min read▶ Video at 52:42🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Sometimes a conflict appears and you're just not ready to deal with it. Maybe it's late, or you need to ask a teammate. There's an emergency exit.

Calm Merges
From the video: Calm Merges
  • Not ready for this conflict?
  • There's an emergency exit
  • Back to before the merge

git merge --abort

The merge failed with a conflict. Git merge, dash dash abort, cancels the whole merge. Status shows a clean working tree, and the file is exactly as it was before. Nothing is lost. You can try the merge again whenever you're ready.

git
git merge title
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
git merge --abort
git status
On branch main
nothing to commit, working tree clean
head -1 index.html
<h1>Sam's Site</h1>

Fewer conflicts

You can't avoid conflicts completely, but you can make them rare, and small. Merge often, so branches don't drift far apart. Keep branches short lived. Make small, focused commits. And talk to your team, when two people need to change the same file.

Merge oftensmall differences
Short branchesdays, not months
Small commitseasy to compare
Talkwho's changing what

Summary

Git merge dash dash abort cancels a merge safely. Merging often keeps conflicts small. Next, your turn to practise branches.

Key takeaways
  • git merge --abort
  • Merge often
  • Short-lived branches
Next up: Practice: Branches — a feature from start to finish