BM: Baca dalam Bahasa Melayu
World 11: Rescue Center
Windows line-ending chaos
You will learn: how one .gitattributes file calms line-ending chaos for everyone.
The problem
Mei fixed one typo on Windows. But git diff says every line changed! Why?
Pick one answer.
This happens to everyone. Here’s the calm way out.
Watch
Every line ends with an invisible line ending. Windows uses two marks: CRLF. Mac and Linux use one: LF. Sort them.
Drag a card into a box. Or tap the card, then tap the box.
Try it
One file fixes it for the whole team. Make .gitattributes with * text=auto. Then commit it.
- Empty
- Empty
- 3 save points
- Add style
- Add day 1 page
- Add README
Hint
Typeecho "* text=auto" > .gitattributes, then git add .gitattributes. Then commit.Watch
Old files may still have the old endings. git add --renormalize . re-adds every tracked file with the new rule. Then commit once.
Try it
Each person can set a helper too. Build the Windows setting.
Tap the pieces in the right order.
Predict
Why commit .gitattributes, not just tell everyone the setting?
Pick one answer.
You did it!
You can now calm line-ending chaos for the whole team.
Go deeper (optional)
Scripts that must keep LF? Add *.sh text eol=lf. Windows-only files? *.bat text eol=crlf. Mark pictures as binary so Git never touches them. Run git add --renormalize . from a clean working folder. GitHub Docs has a full guide.
Bahasa Melayu
Mei baiki satu salah taip di Windows. Tapi git diff kata setiap baris berubah! Kenapa?
Ini berlaku pada semua orang. Ini cara tenang untuk keluar.
Setiap baris berakhir dengan hujung baris (line ending) yang halimunan. Windows guna dua tanda: CRLF. Mac dan Linux guna satu: LF. Susun mereka.
Satu fail baiki untuk seluruh pasukan. Buat .gitattributes dengan * text=auto. Kemudian commit (titik simpan).
echo "* text=auto" > .gitattributes, kemudian git add .gitattributes. Lepas tu commit.Fail lama mungkin masih guna hujung baris lama. git add --renormalize . tambah semula setiap fail yang dijejak dengan peraturan baru. Kemudian commit sekali.
Setiap orang boleh tetapkan pembantu juga. Bina tetapan untuk Windows.
Kenapa commit .gitattributes, bukan sekadar beritahu semua orang tetapannya?
Kini anda boleh tenangkan huru-hara hujung baris untuk seluruh pasukan.
You finished this before. Practice is always welcome!
Official docs: gitattributes (end-of-line conversion) · git add --renormalize · 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?