BM: Baca dalam Bahasa Melayu
World 4: Hello GitHub
Fetch vs pull
You will learn: how to get your team's new commits, and peek before you join them in.
The problem
Aisyah's parcel lands on GitHub. GitHub now has her new commit. Your laptop still shows the old picture.
- ea2c020Add purple stylemain (HEAD is here)origin/main
- f6c78e5Add home page
- 2efd0f2Add README
- ea2c020Add purple stylemain
- f6c78e5Add home page
- 2efd0f2Add README
Aisyah just pushed her diary entry. Your laptop has no idea. How do you find out?
Watch
fetch: Download news from a remote. Your own branches and files stay the same. downloads the news. It moves origin/main only. Your own main and your files stay put.
Try it
Fetch first and look at your laptop. Then pull Aisyah’s entry into main.
- ea2c020Add purple stylemain (HEAD is here)origin/main
- f6c78e5Add home page
- 2efd0f2Add README
- c64aa8eAdd Aisyah's day 2 · Aisyah (only on GitHub)main
- ea2c020Add purple style
- f6c78e5Add home page
- 2efd0f2Add README
Tap an action. Watch the courier.
Hint
Fetch peeks. Pull joins.Predict
You ran git fetch. Did your index.html change?
Pick one answer.
Watch
origin/main is a remote-tracking branch: Your laptop's memory of a remote branch, like origin/main. It moves when you fetch.. It is your laptop’s memory of GitHub. It moves only when you fetch, pull or push.
Check
Fetch or pull? Sort each one.
Drag a card into a box. Or tap the card, then tap the box.
Try it
Type it yourself: fetch, look with git status, then pull.
Hint
git status tells you how far behind you are.You did it!
You can now fetch to peek and pull to catch up.
Go deeper (optional)
git pull is git fetch plus a merge (or a rebase: next lesson). After a fetch, git log --oneline main..origin/main lists what is new. git fetch --prune forgets remote branches that were deleted on GitHub.
Bahasa Melayu
Aisyah baru push catatan diarinya. Laptop anda langsung tak tahu. Macam mana nak tahu?
Fetch (ambil berita) muat turun berita terbaru. Ia gerakkan origin/main sahaja. Main dan fail anda tak berubah.
Fetch dulu dan tengok laptop anda. Kemudian pull catatan Aisyah ke dalam main.
Anda jalankan git fetch. Adakah index.html anda berubah?
origin/main ialah branch penjejak remote. Ia ingatan laptop anda tentang GitHub. Ia hanya bergerak bila anda fetch, pull atau push.
Fetch atau pull? Asingkan setiap satu.
Taip sendiri: fetch, tengok dengan git status, kemudian pull.
git status beritahu berapa jauh anda ketinggalan.Kini anda boleh fetch untuk mengintai dan pull untuk mengejar.
You finished this before. Practice is always welcome!
Official docs: git fetch · git pull · Getting changes from a remote repository
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?