1. What does `git add` do? What’s the staging area?
`git add` places changes into the index (staging area), a buffer where you curate what will go into the next commit.
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Git & Version Control · Question Set
Git & Version Control — Fundamentals interview questions for placements and exams.
Questions
14
Included in this set
Subject
Git & Version Control
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for Git & Version Control.
`git add` places changes into the index (staging area), a buffer where you curate what will go into the next commit.
For complete preparation, combine this set with full subject-wise practice for Git & Version Control. You can also explore other subjects and sets from the links below.
Modern Git: `git switch -c <name>` creates and checks out. Classic equivalent: `git checkout -b <name>`.
`git stash` saves local modifications (tracked files) for later: use `stash pop/apply` to restore.
`git fetch` downloads new refs/history without altering your working branch. `git pull` = fetch + merge (or rebase), integrating changes into the current branch.
Git is a distributed version control system (DVCS) created by Linus Torvalds for fast, reliable source control. It enables branching/merging, offline work, and full history on every clone—ideal for team collaboration and safe iteration.
A repository stores your project files and their version history. A local repo lives on your machine (.git); a remote repo (e.g., GitHub/GitLab) is a shared copy used for collaboration and backup.
'.gitignore' tells Git which files/paths not to track (e.g., builds, secrets). Common patterns: 'node_modules/' and '*.log'. This keeps history clean and avoids committing noise or sensitive data.
# .gitignore node_modules/ *.log .DS_Store /dist/
Stage with `add`, create a snapshot with `commit`, then publish with `push`.
`status` summarizes tracked/untracked/staged; `diff` shows content differences.
A commit is a snapshot of staged changes with metadata (hash, author, time). Clear messages explain intent, aid code review, and improve traceability.
`origin` is the default remote alias created by `git clone`.
A conflict arises when Git can’t auto-merge edits (e.g., same line differs). Open files, choose the correct content, save, `git add` the fixes, then `git commit` (or `--continue`).
Use it to fix the last commit’s message or add missed changes. It rewrites history, so avoid amending commits already pushed/shared.
`git init` bootstraps a repository in the current folder; `git clone` fetches an existing repo, files, branches, and history.