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
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
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.
Hint
Typegit switch -c fix-title, then git push -u origin fix-title.Try it
You opened a pull request. Mei approved it. Merge it into main.
- Yyou
Makes the diary title friendlier.
- Mei approved these changes
Nice fix!
- Passed test
Hint
Scroll down and tap Merge pull request.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.
Bahasa Melayu
Anda push ke main. GitHub tolak: main dilindungi. Fuh! Peraturan buat kerjanya. Commit (titik simpan) anda masih selamat dalam komputer.
Apa yang GitHub mahu dari anda?
Commit anda cuma perlukan branch (cabang). git switch -c fix-title letak label baru padanya, di tempat anda sekarang.
Buat branch itu. Kemudian push ke GitHub.
git switch -c fix-title, kemudian git push -u origin fix-title.Anda dah buka pull request. Mei dah luluskan. Merge (cantum) ke main.
Kenapa anda tak boleh force push saja ke main?
Kini anda boleh masukkan kerja ke branch dilindungi dengan cara yang betul.
You finished this before. Practice is always welcome!
Official docs: About protected branches · git switch · git push
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?