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. Why is the submodule folder empty after cloning, and how do you fix it?

    A normal clone does not download submodule contents. Run git submodule update --init --recursive, or clone with git clone --recurse-submodules next time.

    BeginnerQuick answer1 min read
  2. How do you update a submodule to its latest version?

    Go into the submodule, pull the wanted commit, then commit the changed pointer in the parent. Or run git submodule update --remote to fetch the tracked branch's latest commit for you.

    IntermediateQuick answer1 min read
  3. What is a Git submodule?

    A submodule lets one repository contain another repository at a fixed commit. The parent stores only the URL and the exact commit hash, so the child's history stays separate.

    IntermediateQuick answer1 min read
  4. Why is a submodule in detached HEAD state, and is that a problem?

    The parent pins an exact commit, so Git checks the submodule out at that commit, not on a branch. It is normal. To edit the submodule, check out a branch inside it first, or commits can get lost.

    IntermediateQuick answer1 min read
  5. How do you remove a submodule properly?

    Run git submodule deinit -f path, then git rm -f path, and delete the leftover .git/modules/path folder. Commit the change. Just deleting the folder leaves stale configuration behind.

    AdvancedQuick answer1 min read