Git and Keil are central to my microcontrollers class, but I'm still struggling to understand how they work together. While trying to return my project to the state of my first lab assignment and undo some edits, I accidentally deleted my main.c file. I'm not sure how to recover it or where to start learning the workflow, especially since my professor and TAs avoid giving specific answers that might reveal the lab solutions.
1 Answer
Your file may still be recoverable. Run `git reflog` to see previous positions of HEAD, including before the reset or checkout. Once you find the commit containing the file, restore just main.c with `git checkout -- main.c` or the newer equivalent, `git restore --source= -- main.c`. Avoid running `git clean -fd` until you’re sure you don’t need any untracked files, since that can permanently remove them.

Thanks, I wasn’t sure where to look after the file disappeared. I’ll check the reflog before trying anything else.