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 tag a commit that is not the latest one?

    Give the commit hash after the tag name, for example git tag -a v1.0 3f9c2ab -m 'Release 1.0'. Without a hash, Git tags the current HEAD.

    BeginnerQuick answer1 min read
  2. What is semantic versioning, and how do Git tags relate to it?

    Semantic versioning uses MAJOR.MINOR.PATCH. Bump major for breaking changes, minor for new backward-compatible features, patch for bug fixes. Teams tag each release commit, such as v2.3.1.

    BeginnerQuick answer1 min read
  3. What is the difference between a lightweight tag and an annotated tag?

    A lightweight tag is just a name pointing to a commit. An annotated tag is a full object storing the tagger, date and a message, and can be signed. Annotated tags are recommended for releases.

    BeginnerQuick answer1 min read
  4. Why don't tags appear on GitHub after git push, and how do you push them?

    git push does not send tags by default. Push one with git push origin v1.0, or all with git push --tags. Tags are not created on the remote until you do this.

    BeginnerQuick answer1 min read
  5. How do you work from an old tag, and can you move or delete a tag?

    Checking out a tag puts you in detached HEAD, so create a branch from it with git switch -c fix v1.0. You can delete a tag with git tag -d, but moving a published tag confuses others and should be avoided.

    IntermediateQuick answer1 min read