What is Git?
Learn what Git is, how distributed version control works, snapshots vs diffs, the staging area, and how it differs from GitHub in this interview guide.
Expected Interview Answer
Git is a free, open-source distributed version control system that tracks changes to files over time so teams can collaborate on the same codebase without overwriting each other's work.
Unlike older centralized systems, every developer's clone contains the full project history, so commits, branching, and diffing all happen locally and instantly, with no network round trip required. Git records project state as a series of snapshots rather than file-by-file diffs, and each snapshot (commit) is identified by a SHA-1 hash so history can never be silently altered. Work happens in a staging area (the index) before a commit, giving you fine control over exactly what goes into each snapshot. Because every clone is a full backup, Git is resilient to a single server going down, and features like branching and merging are cheap, encouraging experimentation.
- Full local history means fast commits, diffs, and log lookups
- Cheap, disposable branches encourage experimentation
- Distributed clones give every developer a full backup
- Cryptographic hashing makes history tamper-evident
- Huge ecosystem: GitHub, GitLab, Bitbucket, and CI tooling
AI Mentor Explanation
Git is like the official scorebook of a cricket match, where every over is logged ball by ball instead of just the final total. Each entry is a permanent record you can flip back to, so a scorer can reconstruct exactly how the innings unfolded, who batted when, and where a review changed the outcome.
Step-by-Step Explanation
Step 1
Initialize a repository
`git init` creates a hidden .git directory that stores the entire project history, or `git clone` copies an existing remote repository including all of its history.
Step 2
Track changes with the working directory
Files you edit live in the working directory; Git compares them against the last commit to show what has changed via `git status` and `git diff`.
Step 3
Stage selected changes
`git add` moves specific changes into the staging area (the index), letting you build a commit from exactly the edits you want, not everything you touched.
Step 4
Commit a snapshot
`git commit` permanently records the staged changes as a new commit object, identified by a SHA-1 hash and linked to its parent commit.
Step 5
Branch and merge
Branches are lightweight pointers to commits; you can develop features in isolation on a branch and later merge them back into main.
Step 6
Sync with a remote
`git push` and `git pull` exchange commits with a remote repository like GitHub, keeping your local history and the shared history in sync.
What Interviewer Expects
- Explains Git is distributed, not centralized, and why that matters
- Knows Git stores snapshots, not diffs
- Can describe the working directory, staging area, and repository relationship
- Mentions commits are identified by SHA-1 hashes
- Can contrast Git with older systems like SVN or CVS
Common Mistakes
- Confusing Git with GitHub, treating them as the same thing
- Saying Git stores file diffs instead of full snapshots
- Forgetting the staging area exists between working directory and commit
- Describing Git as centralized like SVN
- Not knowing that every clone contains the complete project history
Best Answer (HR Friendly)
“Git is a tool that keeps a detailed history of every change made to a project's files, so developers can work together, undo mistakes, and see exactly who changed what and when. It's the industry-standard way teams collaborate on code without stepping on each other's work.”
Code Example
$ git init
Initialized empty Git repository in /project/.git/
$ echo "# SkillVeris" > README.md
$ git add README.md
$ git commit -m "Initial commit"
[main (root-commit) 3f2a1b9] Initial commit
1 file changed, 1 insertion(+)
$ git log --oneline
3f2a1b9 (HEAD -> main) Initial commitFollow-up Questions
- What is the difference between Git and GitHub?
- What does 'distributed' mean in distributed version control?
- How does Git use SHA-1 hashes to identify commits?
- What is the staging area and why does it exist?
- How would you explain a merge conflict to a non-technical person?
MCQ Practice
1. What best describes Git?
Git is a distributed version control system, meaning every clone holds the full project history rather than relying on a single central server.
2. How does Git primarily store project history?
Git records the state of the whole project as a snapshot at each commit, referencing unchanged files rather than storing a diff chain.
3. What identifies a specific commit in Git?
Each commit is identified by a SHA-1 hash computed from its content and metadata, which makes history tamper-evident.
Flash Cards
Is Git centralized or distributed? — Distributed — every clone contains the entire project history, not just a working copy.
Does Git store diffs or snapshots? — Snapshots. Each commit represents the full state of tracked files at that point.
What identifies a Git commit? — A SHA-1 hash derived from the commit's content, parent, author, and message.
What sits between the working directory and a commit? — The staging area (index), where you choose exactly what changes go into the next commit.