حفظ التغييرات مؤقتا بإستخدام git stash
ال git stash بتخزن التغييرات غير المحفوظة مؤقتا علشان تقدر ترجع لها بعدين
الأوامر بإستخدام Git Bash أو Bash ونفذ خطوات كل درس بالترتيب داخل مجلد تدريب جديد بعيدا عن مشاريعك
تجهيز مجلد التدريب
mkdir git-practice
cd git-practice
git init -q -b main
git config user.name "Git Learner"
git config user.email "[email protected]"
git config core.autocrlf false
printf 'First Line\n' > notes.txt
git add notes.txt
git commit -q -m "Add Notes"إخفاء تعديل في ملف متتبع
بعد الحفظ المؤقت الملف بيرجع للمحتوى المحفوظ في ال Commit
printf "Draft\n" >> notes.txt
git stash push -q -m "Notes Draft"
cat notes.txtالنتيجة
First Lineإعادة التعديل مع إبقاء النسخة المؤقتة
ال apply بتطبق التغيير ومش بتمسح مدخل ال Stash
git stash apply -q
cat notes.txt
git stash list --format=%sالنتيجة
First Line
Draft
On main: Notes Draftملحوظة
الملفات غير المتتبعة محتاجة الخيار -u علشان تدخل في Stash وإعادة التطبيق ممكن ينتج عنها تعارض