World map

 

BM: Baca dalam Bahasa Melayu

World 11: Rescue Center

I pushed to a protected branch

You will learn: how to get your work into a protected branch the right way.

The problem

Practice repo — not a real website
you / diary
Rules for main

You pushed to main. GitHub refused: main is protected. Phew! The rules did their job. Your commit is still safe on your computer.

Try it

What does GitHub want from you?

Pick one answer.

Watch

A new label, fix-title, appears on the Fix the title commit. HEAD moves onto it.
6d3a9b1a8feb63270a76edf85ccf

Your commit just needs a branch. git switch -c fix-title puts a new label on it, right where you are.

Try it

Make the branch. Then push it to GitHub.

6d3a9b1a8feb63270a76edf85ccf

Try it

You opened a pull request. Mei approved it. Merge it into main.

Practice repo — not a real website
you / diary
Fix the title #8
Open you wants to merge fix-title into main
  1. you

    Makes the diary title friendlier.

  2. Mei approved these changes

    Nice fix!

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

Predict

Why couldn’t you just force push to main?

Pick one answer.

You did it!

You can now get work into a protected branch properly.

Go deeper (optional)

Tidy up afterwards: git switch main, then git pull. Does pull say the branches diverged? The pull request was probably squashed. Your work is on GitHub, so git reset --hard origin/main is safe then. Or, right after pushing your branch, run git branch -f main origin/main.