Beginner Git Interview Questions
1. What is Git?
Git is a distributed version control system used to track changes in code and collaborate with others.
2. What is a repository?
A repository (repo) is a storage location where your project files and version history are kept.
3. What is the difference between Git and GitHub?
Git is a tool for version control, while GitHub is a cloud-based platform that hosts Git repositories.
4. What is a commit?
A commit is a snapshot of changes made to the repository.
5. What is a branch?
A branch is a separate line of development used to work on features or fixes independently.
6. What is the main branch?
The main (or master) branch is the default branch that usually contains stable code.
7. What is cloning?
Cloning means copying a remote repository to your local machine.
8. What is staging?
Staging is the process of preparing changes before committing them.
🟡 Intermediate Git Interview Questions
9. What is the difference between git pull and git fetch?
git fetch: Downloads changes but does not mergegit pull: Fetches and merges changes into your branch
10. What is a merge?
Combining changes from one branch into another.
11. What is a merge conflict?
Occurs when Git cannot automatically resolve differences between branches.
12. What is git rebase?
Reapplies commits on top of another base branch, creating a cleaner history.
13. What is git stash?
Temporarily saves uncommitted changes so you can work on something else.
14. What is .gitignore?
A file that tells Git which files or folders to ignore.
15. What is a remote repository?
A version of your project hosted on the internet or a server.
🔵 Advanced Git Interview Questions
16. What is the difference between merge and rebase?
Merge keeps history as-is, while rebase rewrites commit history for a cleaner timeline.
17. What is cherry-picking?
Applying a specific commit from one branch to another.
18. What is a detached HEAD?
A state where you are not on any branch, just pointing to a specific commit.
19. What is git reset vs git revert?
reset: Removes commits (changes history)revert: Creates a new commit to undo changes
20. What is Git workflow?
A branching strategy that teams use (e.g., feature branch workflow).
21. What is a hook in Git?
Scripts that run automatically before or after certain Git events.
🟣 Scenario-Based Questions
22. How do you resolve a merge conflict?
Edit conflicting files, mark them as resolved, and commit the changes.
23. How do you undo the last commit?
Use git reset (local) or git revert (safe for shared repos).
24. How do you delete a branch?
git branch -d branch_name
25. How do you push code to a remote repository?
git push origin branch_name
26. How do you check commit history?
git log
🧠 Conceptual Questions
27. Why use Git?
It helps track changes, collaborate efficiently, and manage versions safely.
28. What are advantages of Git?
- Distributed system
- Fast performance
- Strong branching support
- Easy collaboration
29. What is version control?
A system that tracks changes to files over time.