Tech

Git

Git is the version control backbone of virtually every modern software team. Beyond basic commits and branches, interviews test your understanding of rebasing, cherry-picking, conflict resolution, and workflows like GitFlow and trunk-based development. Whether you are a developer, DevOps engineer, or technical PM, demonstrating fluency with Git signals professional discipline and teamwork.

What you get

Questions

20

Difficulty

3 levels

Answer Formats

2

Use the toggle on each card to move between an interview-ready answer and a simpler explanation. Questions are sorted from beginner to advanced, and the keywords are highlighted. You can also blur the answers to practice recalling them from memory.

Questions

Practice the answers out loud.

All topics

Question 1

What is Git and why is it used?

Beginner

How to answer in an interview

Git is a distributed version control system used to track changes in source code over time, allowing multiple developers to collaborate without overwriting each other's work. Being distributed means every developer has a full copy of the project history locally, enabling offline work and robust backups.

Question 2

What is the difference between Git and GitHub?

Beginner

How to answer in an interview

Git is the underlying version control tool that tracks changes to files locally on your machine. GitHub is a cloud-based hosting platform built around Git that adds collaboration features like pull requests, issue tracking, and code review, but similar platforms like GitLab and Bitbucket also exist.

Question 3

What is a commit in Git?

Beginner

How to answer in an interview

A commit is a saved snapshot of your project's staged changes at a specific point in time, identified by a unique SHA hash and accompanied by a commit message describing the change. Commits form the building blocks of a project's history, and each one points to its parent commit, forming a chain.

Question 4

Explain branching in Git.

Beginner

How to answer in an interview

A branch is an independent line of development that lets you work on new features or fixes without affecting the main codebase. You can create a branch, make changes and commits on it, and later merge it back into the main branch once the work is complete and tested.

Question 5

What is the difference between git pull and git fetch?

Beginner

How to answer in an interview

git fetch downloads new commits and updates from a remote repository without merging them into your current branch, letting you review changes first. git pull does a fetch followed immediately by a merge (or rebase, depending on configuration) into your current branch.

Question 6

Explain the typical git workflow: add, commit, push.

Beginner

How to answer in an interview

git add stages changes, moving them into the staging area to be included in the next commit. git commit saves the staged changes as a permanent snapshot in the local repository history. git push uploads local commits to a remote repository so others can access them.

Question 7

What is HEAD in Git?

Beginner

How to answer in an interview

HEAD is a reference that points to the current commit or branch you're working on in your local repository, essentially indicating 'where you are' in the project's history. Checking out a different branch or commit moves HEAD accordingly.

Question 8

What is .gitignore used for?

Beginner

How to answer in an interview

.gitignore is a file that specifies patterns for files and directories that Git should not track or stage, such as build artifacts, dependency folders like node_modules, or environment configuration files containing secrets.

Question 9

What is the difference between forking and cloning?

Beginner

How to answer in an interview

Cloning creates a local copy of a repository on your machine, maintaining a connection to the original remote. Forking creates a completely separate copy of a repository under your own account on a platform like GitHub, allowing you to make changes independently and later propose them back via a pull request.

Question 10

What is a pull request?

Beginner

How to answer in an interview

A pull request is a request to merge changes from one branch, often on a fork, into another branch, typically the main branch of the original repository. It provides a platform for code review, discussion, and automated testing before the changes are accepted and merged.

Question 11

What is the difference between merge and rebase?

Intermediate

How to answer in an interview

Merge combines the histories of two branches by creating a new merge commit that ties both histories together, preserving the full branching history. Rebase replays your branch's commits on top of another branch, creating a linear history without a merge commit, which can make history cleaner but rewrites commit hashes, so it should be avoided on shared branches.

Question 12

What is a merge conflict and how do you resolve it?

Intermediate

How to answer in an interview

A merge conflict occurs when Git can't automatically reconcile changes made to the same part of a file in two different branches. To resolve it, you open the file, review the conflict markers Git inserts around the competing changes, manually edit the file to keep the desired result, then stage and commit the resolved file.

Question 13

What is git stash used for?

Intermediate

How to answer in an interview

git stash temporarily saves uncommitted changes in your working directory so you can switch branches or pull updates with a clean working tree, without having to commit incomplete work. You can later reapply the stashed changes using git stash pop or apply.

Question 14

Explain git cherry-pick.

Intermediate

How to answer in an interview

git cherry-pick applies the changes introduced by a specific commit from one branch onto another branch, without merging the entire branch history. It's useful when you want just one particular fix or feature from another branch without bringing in unrelated changes.

Question 15

Explain git tags.

Intermediate

How to answer in an interview

A git tag marks a specific commit as significant, commonly used to denote release versions like v1.0.0. Lightweight tags are simple pointers to a commit, while annotated tags store additional metadata like the tagger's name, date, and message, and are recommended for official releases.

Question 16

What is the difference between git reset and git revert?

Advanced

How to answer in an interview

git reset moves the current branch pointer to a previous commit, optionally modifying the working directory and staging area, and can rewrite history, which is risky on shared branches. git revert creates a new commit that undoes the changes of a specific previous commit without altering existing history, making it safer for shared or public branches.

Question 17

What is a detached HEAD state?

Advanced

How to answer in an interview

A detached HEAD state occurs when you checkout a specific commit instead of a branch, so HEAD points directly to that commit rather than to a branch reference. Any new commits made in this state aren't attached to a branch and can be lost once you switch away, unless you create a new branch to save them.

Question 18

What is the difference between git reset --soft, --mixed, and --hard?

Advanced

How to answer in an interview

git reset --soft moves the branch pointer to a specified commit but leaves the staging area and working directory unchanged, keeping your changes staged. --mixed, the default, moves the pointer and resets the staging area but leaves working directory files unchanged. --hard moves the pointer and resets both the staging area and working directory, permanently discarding uncommitted changes.

Question 19

Explain git bisect.

Advanced

How to answer in an interview

git bisect helps find the commit that introduced a bug by performing a binary search through the commit history. You mark a known good commit and a known bad commit, and Git checks out commits in between, asking you to mark each as good or bad, narrowing down the culprit commit in O(log n) steps.

Question 20

What is a git submodule?

Advanced

How to answer in an interview

A git submodule allows you to embed one Git repository as a subdirectory inside another, keeping the embedded repository's own commit history separate while still tracking a reference to a specific commit within the parent repository. It's often used to include external libraries or shared code as a dependency.

More in Tech

Keep browsing related topics.

Browse all