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
What does
git initdo?How do you clone a repository using
git clone?What is the difference between
git statusandgit log?How do you stage changes using
git add?What does
git commit -mdo?How do you view commit history?
What is the difference between
git diffandgit show?How do you configure Git user details?
What is
.gitignoreand how is it used?How do you check the current branch?
2. Branching
How do you create a new branch in Git?
What is the difference between
git branchandgit checkout -b?How do you switch between branches?
What is a detached HEAD state?
How do you delete a branch locally?
How do you delete a branch remotely?
What is the difference between
git mergeandgit rebase?How do you resolve merge conflicts?
How do you squash commits?
How do you rename a branch?
3. Remote
How do you add a remote repository?
What does
git remote -vshow?How do you push changes to a remote branch?
Difference between
git pullandgit fetch?How do you set upstream branch for tracking?
How do you clone a specific branch?
How do you fetch all branches from remote?
How do you push tags to remote?
How do you remove a remote?
How do you handle multiple remotes?
4. Undo & Cleanup
How do you unstage a file in Git?
Difference between
git reset --soft,--mixed, and--hard?How do you revert a commit?
How do you undo the last commit without losing changes?
What does
git stashdo?How do you apply stashed changes?
How do you drop stashed changes?
How do you clean untracked files?
How do you recover a deleted branch?
What is
git reflogand why is it useful?
5. Advanced
What is
git cherry-pick?How do you use
git bisectto find bugs?What are Git hooks and how are they used?
How do you create and use tags in Git?
What is the difference between lightweight and annotated tags?
How do you sign commits in Git?
How do you configure Git aliases?
How do you handle large files in Git?
How do you use submodules in Git?
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
Post a Comment