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 →
- How do you delete a branch locally and on the remote?
Delete it locally with git branch -d name (or -D to force), and delete it on the remote with git push origin --delete name. They are separate; removing one does not remove the other.
BeginnerQuick answer1 min read - How do you find which branches are already merged into main?
Run git branch --merged main to list branches whose commits are all in main, and git branch --no-merged main for the rest. Merged ones are usually safe to delete.
BeginnerQuick answer1 min read - How do you rename a Git branch, including one already pushed?
Locally use git branch -m old new. For a pushed branch, push the new name, set its upstream, and delete the old name on the remote. Tell teammates, since their copies still track the old name.
BeginnerQuick answer1 min read