0Pricing
Git Advanced: Monorepo, Submodules & Workflows · درس

Reflog للاسترداد

تعرّف على `git reflog` بوصفه شبكة أمان لاسترداد الالتزامات أو الفروع المفقودة أو عمليات إعادة الضبط غير المقصودة.

Reflog للاسترداد درس مجاني في Git Advanced: Monorepo, Submodules & Workflows على CoddyKit. هذا هو الدرس 3 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Git Advanced: Monorepo, Submodules & Workflows، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Git Advanced: Monorepo, Submodules & Workflows 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Your Git Safety Net

git reflog is a journal of every move your HEAD makes — commit, checkout, merge, rebase, reset. It's a powerful safety net for recovering lost work.

Git's Head & Reference Logs

HEAD points to your current position, and the reflog records everywhere it's been. It lives locally on your machine — not in the shared repo history.

Viewing Your Reflog

Run git reflog to see each action indexed as HEAD@{0}, HEAD@{1}, and so on — with the commit hash, the move, and a timestamp.

git reflog

Deciphering Reflog Output

Read reflog output as a stack: HEAD@{0} is your current state, HEAD@{1} the one before it. Each entry marks where HEAD changed.

Recovering from a Hard Reset

Accidentally ran git reset --hard HEAD~2? Don't panic — those commits aren't gone, just unreachable. The reflog still remembers where HEAD was before the reset.

Using Reflog to Undo Resets

Find the commit before your bad reset in git reflog, then recover it with git reset --hard <hash> — or use the index directly, like HEAD@{2}.

Rescuing a Deleted Branch

Deleted a branch with git branch -D? Its commits still live in your reflog, since HEAD's movements onto that branch were all recorded.

Recreating a Lost Branch

Find the deleted branch's last commit in the reflog, then recreate it: git branch my-feature <hash>. Check it out and you're back in business.

Reflog Expiration

Reflog entries don't last forever: reachable ones expire after 90 days, unreachable ones after 30. It's a safety net, not a backup — always push important work.

Reflog Recovery Quiz

You accidentally ran git reset --hard HEAD~3 and lost your last three commits. You check git reflog and see:

a1b2c3d HEAD@{0}: reset: moving to HEAD~3
e4f5g6h HEAD@{1}: commit: Final bug fix
f7e8d9c HEAD@{2}: commit: Implement new feature
i7j8k9l HEAD@{3}: commit: Initial setup

Which command would restore your repository to the state before the reset, bringing back "Final bug fix" and "Implement new feature"?

Reflog: Your Git Lifesaver

Recap: git reflog logs everywhere HEAD has been, your first defense against bad resets and lost branches. Recover with git reset --hard HEAD@{n} — but it does expire.

الأسئلة الشائعة

هل درس «Reflog للاسترداد» مجاني؟

نعم — نص درس «Reflog للاسترداد» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Git Advanced: Monorepo, Submodules & Workflows، انتقل إلى CoddyKit PRO. تتضمن دورة Git Advanced: Monorepo, Submodules & Workflows 4 دروس في المجموع.

ماذا ستتعلم في «Reflog للاسترداد»؟

تعرّف على `git reflog` بوصفه شبكة أمان لاسترداد الالتزامات أو الفروع المفقودة أو عمليات إعادة الضبط غير المقصودة. تتمرن على Git Advanced: Monorepo, Submodules & Workflows مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Git Advanced: Monorepo, Submodules & Workflows؟

لا تُشترط خبرة سابقة. Git Advanced: Monorepo, Submodules & Workflows على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 3 من أصل 4.

كم من الوقت يستغرق درس «Reflog للاسترداد»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Git Advanced: Monorepo, Submodules & Workflows هذا؟

نعم. كل درس في Git Advanced: Monorepo, Submodules & Workflows يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. إعادة الأساس التفاعلية وتعديل الالتزامات
  2. تخزين التغييرات وانتقاؤها
  3. Reflog للاسترداد
  4. Bisect: البحث عن الالتزامات المعيبة
← العودة إلى Git Advanced: Monorepo, Submodules & Workflows