Interview Q&A / Git & GitHub
Git & GitHub interview questions
Branching, merge vs rebase, resolving conflicts and pull requests, the way teams actually work.
Prefer rapid revision? Practise Git & GitHub short interview answers →
- 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 - What is branch protection on GitHub, and what rules can you set?
Branch protection rules guard important branches like main. You can require pull requests, a number of approvals, passing status checks, up-to-date branches, and block force pushes and deletion.
BeginnerQuick answer1 min read