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 .gitignore, and what would you do if you accidentally committed a password or API key?

    .gitignore lists files Git should not track, like .env, node_modules and build output. If a secret was committed, first revoke or rotate it, because anyone who saw it can use it. Then stop tracking the file, add it to .gitignore, and if it was pushed, remove it from history with git filter-repo or BFG and force push.

    IntermediateIn-depth4 min read
  2. How do you use secrets such as API keys in GitHub Actions safely?

    Store them under repository Settings, Secrets and variables, then read them in the workflow as secrets.NAME. GitHub masks their values in logs, and they are not passed to workflows from forks by default.

    IntermediateQuick answer1 min read