Interview Q&A / Git & GitHub

INTERVIEW Q&A · 97 QUESTIONS

Git & GitHub interview questions

Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.

  1. What is git stash, and when would you use it?

    git stash saves your uncommitted changes in a temporary stack and gives you a clean working directory, so you can switch branches or pull without committing half-done work. Later, git stash pop brings the changes back and removes them from the stack; git stash apply brings them back but keeps the stash.

    BeginnerIn-depth3 min read
  2. Does git stash save untracked files, and how do you include them?

    By default git stash saves only tracked changes. Add -u (--include-untracked) to also stash new files, or -a to include ignored files as well.

    BeginnerQuick answer1 min read
  3. How do you list, name and inspect your stashes?

    Save with git stash push -m 'message' so each stash has a label, list them with git stash list, and see their contents with git stash show -p stash@{n}.

    BeginnerQuick answer1 min read
  4. What is the difference between git stash pop and git stash apply?

    Both reapply stashed changes to your working tree. pop also deletes the stash entry afterwards, while apply keeps it, so you can reuse it on another branch.

    BeginnerQuick answer1 min read