# reflog से काम वापस पाना — Git Fundamentals: Commits, Branches और Collaboration

Source: https://www.geekswithgeeks.com/hi/git/git-reflog

> reset, rebase या हटाई गई branch के बाद खोए लगने वाले commits को git reflog से खोजें और बहाल करें।

## सुरक्षा जाल

`git reflog` हर उस जगह को दर्ज करता है जहाँ `HEAD` रहा है, `reset --hard`, खराब rebase या हटाई गई branch के बाद भी। Garbage collection तक commits हफ्तों तक recover हो सकते हैं।

## खोया commit बहाल करें

Reflog में commit खोजें, फिर किसी branch को उस पर ले जाएँ।

```bash
git reflog
# a1b2c3d HEAD@{2}: commit: Add search feature
git switch -c rescued a1b2c3d     # new branch at the lost commit
# or
git reset --hard a1b2c3d
```

Reflog केवल local है और कभी push नहीं होता। कुछ जोखिम भरा चलाने से पहले मौजूदा commit hash नोट कर लें।

त्वरित जाँच

**Quiz:** कौन-सा command बताता है कि HEAD कहाँ-कहाँ रहा, ताकि खोए commits recover हों?

- [x] git reflog
- [ ] git log --stat
- [ ] git blame
- [ ] git remote -v

*Answer:* git reflog. Reflog resets के बाद भी HEAD की गतिविधि दर्ज करता है।
