World map

 

BM: Baca dalam Bahasa Melayu

World 5: Teamwork

Merge, squash or rebase?

You will learn: the three ways to merge a pull request, and when to pick each.

The problem

main has two neat commits. After a plain merge, it also gets wip, oops, fix typo, fix again, and one more: Merge pull request #18.

Mei’s PR has 4 messy commits. A plain merge copies them all onto main. Then it adds a merge commit on top. Is that what you want?

Predict

This time you pick squash and merge: Merge a pull request as one single, tidy commit.. What lands on main?

Pick one answer.

Watch

Ravi's PR has three neat commits. They land on main one by one: Add gallery page, Add photos, Add captions. No merge commit.

Ravi’s commits are already neat. rebase and merge: Copy each commit of a pull request onto main, one by one, with no merge commit. copies each one onto main. No merge commit. History stays one straight line.

Try it

Back to Mei’s messy PR. Squash and merge it.

Practice repo — not a real website
kelab-kod / club-site
Add photo gallery #18
Open mei wants to merge gallery into main
  1. mei

    Adds the gallery page.

    4 commits: wip, oops, fix typo, fix again

  2. Aina approved these changes

    Lovely! Please squash those commits.

Checks
  • Passed test
How to merge
Ready to merge.
Your review

Check

Which merge method fits? Sort each one.

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

        Predict

        A branch rule says: keep history in one straight line. Which method is blocked?

        Pick one answer.

        You did it!

        You can now pick merge, squash or rebase for each pull request.

        Go deeper (optional)

        Rebase and merge makes new commits, with new hashes. Squash loses each small commit’s own message and author time. A repo can switch off the methods it does not want. With a merge queue, the queue picks the method for you.