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. 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
  2. What does 'Your branch is ahead of origin/main by 2 commits' mean?

    You have two local commits that are not on the remote yet. Nothing is wrong. Run git push to publish them. If it says behind, the remote has commits you do not have yet.

    BeginnerQuick answer1 min read
  3. What is origin in Git, and can a repo have more than one remote?

    origin is the default name Git gives to the remote you cloned from. It is just a nickname for a URL, and a repository can have many remotes, such as origin and upstream for a fork.

    BeginnerQuick answer1 min read