Git & GitHub
/Advanced
Troubleshooting Questions
Definition
Questions specifically focused on finding bugs, isolating problematic code, and fixing broken repository states.
Explain Like I'm New
Testing if you know the advanced commands required to hunt down elusive bugs in massive codebases.
Real World Example
Explaining how to use `git bisect`.
Common Use Cases
- •Senior/Lead Engineer Interviews
Terminal Output
bash / terminal
/*
Q: A colleague forces pushed to `main` and deleted 5 important commits.
Is the code gone forever? How do you get it back?
A:
The code is NOT gone. If the colleague previously pulled those 5 commits
to their local machine, those commits are stored in their local `git reflog`.
1. Have the colleague run `git reflog`.
2. Find the hash of the commit right before they did the force push.
3. Run `git reset --hard <that-hash>` to restore the commits locally.
4. Run `git push --force` to restore them on the GitHub server.
*/
Interview Questions
basic
- What command shows you who last edited a specific line of code?
intermediate
- How does `git bisect` work?