Git & GitHub Course
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?

Flash Cards

Question

Who edited this?

Click to reveal answer
Answer

`git blame <filename>`. It annotates every line of the file with the name of the author and the commit hash.

Question

How bisect works?

Click to reveal answer
Answer

It performs a binary search through commit history. You give it a 'good' commit and a 'bad' commit. It jumps to the middle commit and asks you if it is broken. Based on your answer, it halves the search area again. It finds the exact commit that introduced a bug in a fraction of the time it would take to check manually.