ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
ဒီ exercise set ကတော့ Basic chapter မှာ သင်ခဲ့တဲ့ repository initialize, staging, committing, နှင့် ignoring files စတဲ့ core skill များကို quick self-test လုပ်ဖို့ ရည်ရွယ်ပါတယ်။ New concept တွေ သင်ပေးမှာမဟုတ်ဘဲ, သင်ယူထားပြီးသား command တွေကို repetition ဖြင့် ပိုမို ကျွမ်းကျင်စေမှာ ဖြစ်ပါတယ်။ task တစ်ခုစီကို terminal ဖွင့်ပြီး လက်တွေ့ run ကြည့်ဖို့ အကြံပြုပါတယ်။
လေ့ကျင့်ခန်းများ
Task 1: 'my-notes' ဆိုတဲ့ folder အသစ်တစ်ခု ဖန်တီးပြီး git init လုပ်ကာ, notes.txt ဆိုတဲ့ file တစ်ခု ဖန်တီးပြီး 'Initial notes' message နှင့် commit လုပ်ပါ။ Task 2: notes.txt ကို နောက်ထပ် line နှစ်ကြောင်း ထပ်ဖြည့်ပြီး, git diff ဖြင့် changes ကို commit မလုပ်ခင် ကြည့်ကြည့်ပါ, ပြီးမှ commit လုပ်ပါ။ Task 3: temp.log ဆိုတဲ့ file တစ်ခု ဖန်တီးပြီး, .gitignore ထဲမှာ *.log ကို ထည့်ပြီး git status ဖြင့် temp.log က track မဖြစ်ကြောင်း confirm လုပ်ပါ။ Task 4: git log --oneline ဖြင့် commit history အားလုံးကို review လုပ်ပါ။
Code နမူနာ
# Task 1
mkdir my-notes
cd my-notes
git init
echo "Meeting notes" > notes.txt
git add notes.txt
git commit -m "Initial notes"
# Task 2
echo "Follow up with team" >> notes.txt
echo "Review PR by Friday" >> notes.txt
git diff
git add notes.txt
git commit -m "Add follow-up items"
# Task 3
echo "debug output" > temp.log
printf "*.log\n" >> .gitignore
git status
# Task 4
git log --onelineTask 4 ပြီးနောက် git log --oneline မှာ commit နှစ်ခု ပေါ်လာပြီး, temp.log က git status output ထဲမှာ လုံးဝ မပါဝင်တော့ပါ။၅ မိနစ် စမ်းကြည့်
notes.txt အစား second-notes.txt ဆိုတဲ့ file အသစ်တစ်ခု ဖန်တီးပြီး task 1-4 အားလုံးကို scratch ကနေ ပြန်ကျင့်ကြည့်ပါ (5 မိနစ်).
သတိလေးတစ်ချက်
file တစ်ခုကို တစ်ခါ git add ဖြင့် track လုပ်ပြီးသားဆိုရင် .gitignore ထဲထည့်ရုံနဲ့ untrack မဖြစ်ပါ — git rm --cached <file> ဖြင့် အရင် untrack လုပ်ရပါမည်။