Top Git Interview Questions and Answers (Beginner to Advanced)

Whether you’re preparing for a software engineering interview or brushing up on your Git knowledge, being ready for Git-related questions is essential.
This guide covers basic, intermediate, and advanced Git interview questions and answers with examples, so you can walk into your next interview with confidence.


🔹 Beginner-Level Git Interview Questions

1. What is Git?

Answer: Git is a distributed version control system that tracks changes in source code, allowing multiple developers to collaborate. Unlike centralized systems, Git lets every developer have a full copy of the repository.


2. What is the difference between Git and GitHub?

Answer:

  • Git → Version control system for managing source code.
  • GitHub → Hosting service for Git repositories, providing collaboration tools like pull requests, issues, and CI/CD integration.

3. What is a Git repository?

Answer: A repository (repo) is a storage space where Git tracks all project files and history. It can be local (on your machine) or remote (on GitHub, GitLab, Bitbucket, etc.).


4. What is the difference between git fetch and git pull?

Answer:

  • git fetch → Downloads new changes from a remote but doesn’t merge them.
  • git pull → Fetches + merges changes into your current branch.

5. How do you check the current branch in Git?

git branch

The active branch is marked with an asterisk *.


🔹 Intermediate-Level Git Interview Questions

6. What are Git branches, and why are they important?

Answer: Branches allow parallel development without affecting the main branch. Commonly used workflows: feature branches, release branches, hotfix branches.


7. What is the difference between git merge and git rebase?

Answer:

  • Merge → Combines changes, preserves history.
  • Rebase → Reapplies commits on top of another branch, creates a linear history.

8. What is a detached HEAD in Git?

Answer: A detached HEAD happens when you checkout a commit (not a branch). You can still make changes, but unless you create a branch, those changes may be lost.


9. How do you undo the last Git commit?

  • Keep changes staged: git reset --soft HEAD~1
  • Keep changes unstaged: git reset HEAD~1
  • Discard changes completely: git reset --hard HEAD~1

10. What is the difference between git reset and git revert?

Answer:

  • git reset → Moves HEAD, can rewrite history (dangerous on shared repos).
  • git revert → Creates a new commit that undoes a previous one (safe for shared repos).

🔹 Advanced-Level Git Interview Questions

11. What is git reflog, and when would you use it?

Answer: git reflog records all changes to HEAD. It helps recover lost commits after a reset, rebase, or branch deletion.

Example:

git reflog
git reset --hard HEAD@{3}


12. What is Git Cherry-Pick?

Answer: git cherry-pick <commit> applies a specific commit from one branch onto another. Useful for bug fixes or selective features.


13. How do you resolve a merge conflict in Git?

Answer:

  1. Open conflicted files.
  2. Look for conflict markers (<<<<<<<, =======, >>>>>>>).
  3. Edit to keep the correct code.
  4. Mark resolved: git add <file> git commit

14. What are Git Hooks?

Answer: Git hooks are custom scripts triggered by Git actions (e.g., pre-commit, post-merge). Example: running linters automatically before commits.


15. What is the difference between Git LFS and normal Git?

Answer:

  • Git LFS (Large File Storage) manages large files like images, binaries by storing pointers in Git and actual files in remote storage.
  • Normal Git → Stores everything inside .git leading to repo bloat.

16. How do you find which commit introduced a bug?

Answer: Using git bisect:

git bisect start
git bisect bad
git bisect good &lt;commit>

Git performs a binary search to identify the bad commit.


17. How do you create and delete Git tags?

  • Create tag: git tag v1.0.0 git push origin v1.0.0
  • Delete tag: git tag -d v1.0.0 git push origin :refs/tags/v1.0.0

18. What’s the difference between git clone --depth 1 and a normal clone?

Answer:

  • git clone --depth 1 → Creates a shallow clone with only the latest commit (faster, smaller).
  • Normal clone → Full commit history.

✅ Key Takeaways

  • Basic Git questions test your understanding of repositories, commits, and branches.
  • Intermediate questions focus on workflows, resets, merges, rebases.
  • Advanced questions test your ability to debug, recover, and optimize Git usage.

Mastering these questions will help you ace Git interviews and strengthen your daily development workflow.

You Might Also Like

🛠️ Recommended Tools for Developers & Tech Pros

Save time, boost productivity, and work smarter with these AI-powered tools I personally use and recommend:

1️⃣ CopyOwl.ai – Research & Write Smarter
Write fully referenced reports, essays, or blogs in one click.
✅ 97% satisfaction • ✅ 10+ hrs saved/week • ✅ Academic citations

2️⃣ LoopCV.pro – Build a Job-Winning Resume
Create beautiful, ATS-friendly resumes in seconds — perfect for tech roles.
✅ One-click templates • ✅ PDF/DOCX export • ✅ Interview-boosting design

3️⃣ Speechify – Listen to Any Text
Turn articles, docs, or PDFs into natural-sounding audio — even while coding.
✅ 1,000+ voices • ✅ Works on all platforms • ✅ Used by 50M+ people