BM: Baca dalam Bahasa Melayu
World 1: Save Points
HEAD: you are here
You will learn: what HEAD is, and how it moves when you commit.
The problem
You have four save points. Which one are you standing on right now? Games show a “you are here” dot. Git has one too.
Watch
See HEAD on the top line? HEAD is Git’s “you are here” marker. Right now it sits on your newest commit.
Try it
On the graph, HEAD is the pink marker. Find it.
Tap the commit HEAD points at.
Hint
Look for the pink tag that says HEAD.Watch
HEAD points at a branch: a named line of commits. Yours is called main. git branch lists branches. The * marks the one HEAD points at.
Predict
You make one more commit. Where does HEAD end up?
Pick one answer.
Watch
The new commit lands. main moves onto it, and HEAD rides along with main. That is why you always stay at the front.
You did it!
You can now find HEAD and predict where it goes next.
Go deeper (optional)
Git keeps HEAD in a tiny file, .git/HEAD. Most of the time it says ref: refs/heads/main, which means “HEAD points at main”. In World 2, you will move HEAD onto an old commit. That is called a detached HEAD.
Bahasa Melayu
Anda ada empat titik simpan. Anda sedang berdiri di titik yang mana sekarang? Dalam game, peta ada titik “anda di sini”. Git pun ada.
Nampak HEAD pada baris atas? HEAD ialah penanda “anda di sini” dalam Git. Sekarang ia berada pada commit (titik simpan) terbaru anda.
Pada graf, HEAD ialah penanda merah jambu. Cari penanda itu.
HEAD tunjuk ke satu branch (barisan commit yang ada nama). Branch anda bernama main. git branch senaraikan branch. Tanda * ialah yang HEAD tunjuk.
Anda buat satu lagi commit. Di mana HEAD akan berada?
Commit baru masuk. main bergerak ke atasnya, dan HEAD ikut sekali dengan main. Sebab itu anda sentiasa berada di depan.
Kini anda boleh cari HEAD dan teka ke mana ia pergi seterusnya.
You finished this before. Practice is always welcome!
Official docs: gitglossary (HEAD) · git branch · git log
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?