BM: Baca dalam Bahasa Melayu
World 3: Parallel Universes
Rebase basics
You will learn: to move your branch on top of the newest main.
The problem
main moved on while you built about. You want your work on top of the newest main. Without a merge commit.
Watch
git rebase main replays your commits on top of main, one by one. Like moving your work to the end of the line. That’s a rebase: Replay your commits on top of another branch. They become new commits..
Try it
You are on about. Rebase it onto main.
Hint
Typegit rebase main, then press Enter.Watch
Look at the ids. Same messages, new hashes! A rebase makes new copies of your commits.
Predict
about now sits right on top of main. You merge about into main. What happens?
Pick one answer.
Try it
Bring about into main. Watch for a fast-forward!
Hint
Switch to main. Then merge about.You did it!
You can now rebase a branch onto the newest main.
Go deeper (optional)
A rebase can stop on a conflict too. Fix the file and git add it. Then run git rebase --continue. Changed your mind? git rebase --abort puts everything back. The bottom marker names the commit being replayed.
Bahasa Melayu
main dah bergerak semasa anda bina about. Anda nak kerja anda di atas main yang terkini. Tanpa merge commit.
git rebase main main semula commit anda di atas main, satu demi satu. Macam alihkan kerja anda ke hujung barisan. Itulah rebase (asas semula).
Anda di about. Rebase ke atas main.
git rebase main, kemudian tekan Enter.Tengok id itu. Mesej sama, hash baru! Rebase buat salinan baru commit anda.
about kini betul-betul di atas main. Anda merge about ke main. Apa jadi?
Bawa about masuk ke main. Perhatikan fast-forward!
Kini anda boleh rebase branch ke atas main yang terkini.
You finished this before. Practice is always welcome!
Official docs: git rebase
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?