BM: Baca dalam Bahasa Melayu
World 10: Deep Git
Aliases, includeIf, line endings
You will learn: three config powers: short names, settings per folder, and calm line endings.
The problem
You type this long command twenty times a day. That is a lot of keys! Can Git give it a short name?
Try it
An alias: Your own short name for a Git command, like git st for git status. is your own short name for a command. Build one: git lg will draw your history.
Tap the pieces in the right order.
Try it
Now make git st mean git status. Then try it.
Hint
Typegit config --global alias.st status, then git st.Predict
You make an alias called status that runs log. What does git status do now?
Pick one answer.
Watch
includeIf: A config rule that loads extra settings only in some folders. loads extra settings in some folders only. Every repo inside ~/work/ uses Aina’s work email.
Try it
line ending: The invisible mark at the end of each line. Windows uses CRLF; macOS and Linux use LF. differ: Windows uses CRLF, Mac and Linux use LF. A .gitattributes: A file in your repo that tells Git how to treat some files, like line endings or binary files. file sets one rule for the whole team. Make one and commit it.
- Empty
- Empty
- 2 save points
- Add day 2
- Add home page
Hint
* text=auto lets Git handle line endings in text files. *.png binary tells Git to never touch pictures.Check
Which tool does each job?
Drag a card into a box. Or tap the card, then tap the box.
You did it!
You can now shorten commands, set folder rules and calm line endings.
Go deeper (optional)
On Windows, git config --global core.autocrlf true gives CRLF on your desk and LF in Git. On Mac or Linux, use input. Put includeIf after [user], so its email wins. An alias that starts with ! runs a shell command. Line endings already messy? See the World 11 lesson “Windows line-ending chaos”.
Bahasa Melayu
Anda taip arahan panjang ini dua puluh kali sehari. Banyak betul kekunci! Boleh Git beri ia nama pendek?
Alias (nama samaran) ialah nama pendek anda sendiri untuk sesuatu arahan. Bina satu: git lg akan lukis sejarah anda.
Sekarang jadikan git st sama dengan git status. Kemudian cuba.
git config --global alias.st status, kemudian git st.Anda buat alias bernama status yang jalankan log. Apa yang git status buat sekarang?
includeIf muatkan tetapan tambahan dalam folder tertentu sahaja. Setiap repo dalam ~/work/ guna e-mel kerja Aina.
Hujung baris (line ending) berbeza. Windows guna CRLF, Mac dan Linux guna LF. Fail .gitattributes tetapkan satu peraturan untuk seluruh pasukan. Buat satu dan commit.
* text=auto biar Git uruskan hujung baris fail teks. *.png binary suruh Git jangan usik gambar.Alat mana buat setiap kerja?
Kini anda boleh pendekkan arahan, tetapkan peraturan folder dan tenangkan hujung baris.
You finished this before. Practice is always welcome!
Official docs: git config (alias, includeIf) · gitattributes · Configuring Git to handle line endings
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?