Top 50 Git Command Interview Questions πŸš€


Introduction

Git is the most widely used distributed version control system. Interviewers often test candidates on their ability to use Git commands effectively for version control, collaboration, and recovery. This blog organizes the Top 50 Git Command Interview Questions into structured sections for easy preparation.


1. Basics

  1. What does git init do?

  2. How do you clone a repository using git clone?

  3. What is the difference between git status and git log?

  4. How do you stage changes using git add?

  5. What does git commit -m do?

  6. How do you view commit history?

  7. What is the difference between git diff and git show?

  8. How do you configure Git user details?

  9. What is .gitignore and how is it used?

  10. How do you check the current branch?


2. Branching

  1. How do you create a new branch in Git?

  2. What is the difference between git branch and git checkout -b?

  3. How do you switch between branches?

  4. What is a detached HEAD state?

  5. How do you delete a branch locally?

  6. How do you delete a branch remotely?

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

  8. How do you resolve merge conflicts?

  9. How do you squash commits?

  10. How do you rename a branch?


3. Remote

  1. How do you add a remote repository?

  2. What does git remote -v show?

  3. How do you push changes to a remote branch?

  4. Difference between git pull and git fetch?

  5. How do you set upstream branch for tracking?

  6. How do you clone a specific branch?

  7. How do you fetch all branches from remote?

  8. How do you push tags to remote?

  9. How do you remove a remote?

  10. How do you handle multiple remotes?


4. Undo & Cleanup

  1. How do you unstage a file in Git?

  2. Difference between git reset --soft, --mixed, and --hard?

  3. How do you revert a commit?

  4. How do you undo the last commit without losing changes?

  5. What does git stash do?

  6. How do you apply stashed changes?

  7. How do you drop stashed changes?

  8. How do you clean untracked files?

  9. How do you recover a deleted branch?

  10. What is git reflog and why is it useful?


5. Advanced

  1. What is git cherry-pick?

  2. How do you use git bisect to find bugs?

  3. What are Git hooks and how are they used?

  4. How do you create and use tags in Git?

  5. What is the difference between lightweight and annotated tags?

  6. How do you sign commits in Git?

  7. How do you configure Git aliases?

  8. How do you handle large files in Git?

  9. How do you use submodules in Git?

  10. What are best practices for Git in enterprise projects?


Conclusion

These 50 questions cover the breadth of Git command knowledge expected from experienced developers. From basics and branching to remote operations, undo strategies, and advanced scenarios, this list serves as a comprehensive guide for interview preparation. By mastering these commands and practicing with real repositories, you’ll be ready to tackle interviews confidently.


This was part of Interview Preparation With Bipin — Let’s Crack It!

Comments

Popular posts from this blog

Angular Architecture

Why should I learn Angular?

Solid Principle