Master Interviews
Anywhere, Anytime
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
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 · Complete Question Bank
Practice the complete collection of Git & Version Control interview questions including theory, coding, MCQs and real interview problems.
Questions
163
Full database
Topics
57
Categorised
Difficulty
Mixed Levels
Easy Hard
Scroll through every important Git & Version Control question asked in real interviews. Includes MCQs, subjective questions, and coding prompts.
Browse more Git & Version Control questions, explore related subjects, or practice full interview sets to strengthen your preparation.
# .gitignore node_modules/ *.log .DS_Store /dist/
Correct Answer: `git init` creates a new empty repo; `git clone` copies an existing repo with history.
Correct Answer: git add → git commit → git push
Correct Answer: `git status` (state) and `git diff` (line changes)
Correct Answer: The default remote pointing to the cloned URL
Correct Answer: `git switch -c feature/ui`
Correct Answer: Temporarily shelves uncommitted changes and reverts to a clean work tree
Correct Answer: git switch -c feature/api
Correct Answer: git branch --set-upstream-to=origin/develop
Correct Answer: git merge feature/ui
Correct Answer: Fix files → git add <files> → git commit
Correct Answer: git push --set-upstream origin bugfix/typo
Correct Answer: git revert <hash>
Correct Answer: git pull --rebase
Correct Answer: `git branch -d <name>` then `git fetch --prune`
Correct Answer: git add -u
Correct Answer: git add -p
Correct Answer: git add missing.js; git commit --amend
Correct Answer: git restore --staged <file>
Correct Answer: git log --oneline --graph --decorate --all
Correct Answer: git diff --staged
Correct Answer: git restore app.js
Correct Answer: git commit -S -m "msg"
Correct Answer: git remote set-url origin <new-url>
Correct Answer: `git pull` is equivalent to `git fetch` followed by `git merge` (or rebase per config).
Correct Answer: git fetch --prune
Correct Answer: git push origin :feature/login
Correct Answer: git pull --rebase
Correct Answer: git push origin --tags
Correct Answer: git clone --depth 1 <url>
Correct Answer: git worktree
Correct Answer: Rebase rewrites commits onto a new base to create linear history; merge preserves branch topology.
Correct Answer: Forces a merge commit to preserve the feature branch identity.
Correct Answer: git rebase -i --autosquash origin/main
Correct Answer: Edit → git add → git rebase --continue
Correct Answer: All commits from the PR are condensed into a single commit on the target branch.
Correct Answer: git merge -X ours
Correct Answer: Remembers how you resolved a conflict and reapplies it next time the same conflict appears.
Correct Answer: Require rebase before merging + use squash merge for PRs.
Correct Answer: git reset --mixed <commit>
Correct Answer: When you need to undo a public commit without rewriting shared history.
Correct Answer: Both index and working tree changes since that commit
Correct Answer: git revert abc123
Correct Answer: You are in detached HEAD; new commits won’t belong to a branch unless you create one.
Correct Answer: git fetch origin && git reset --hard origin/main
Correct Answer: git push --force-with-lease
Correct Answer: git switch -C feature/login
Correct Answer: When the target branch tip can be moved forward without a merge commit
Correct Answer: To enforce a merge commit for clearer feature grouping/history
Correct Answer: Rebase changes commit hashes and should not be used on already-pushed shared history
Correct Answer: Combines all feature commits into one commit on the target branch
Correct Answer: git branch --set-upstream-to=origin/main
Correct Answer: A merge of more than two branches at once
Correct Answer: git stash
Correct Answer: `apply` reapplies changes and keeps the stash; `pop` reapplies and removes the stash entry
Correct Answer: git stash -u
Correct Answer: git stash --all
Correct Answer: git stash push -m "msg"
Correct Answer: git stash -p
Correct Answer: -f -d
Correct Answer: git clean -fx
Correct Answer: Trunk-based: short-lived branches from main with PRs and frequent deploys
Correct Answer: main and develop
Correct Answer: To share early work for feedback/CI while signaling it’s not ready to merge
Correct Answer: Auto-assign reviewers and optionally require their approval for specific paths
Correct Answer: Rebase and merge
Correct Answer: Squash and merge
Correct Answer: Fixes #123
Correct Answer: On your personal feature branch before pushing
Correct Answer: squash
Correct Answer: git config pull.rebase true
Correct Answer: `git rebase --continue` / `git rebase --abort`
Correct Answer: git cherry-pick A..B
Correct Answer: --signoff
Correct Answer: Create fixup commits → git rebase -i --autosquash base
Correct Answer: git tag -a v1.2.0 -m "Release 1.2.0"
Correct Answer: git push origin v2.0.0
Correct Answer: git tag -d v1.0.0; git push origin :refs/tags/v1.0.0
Correct Answer: MAJOR
Correct Answer: 2.1.0-preview+001
Correct Answer: git tag -s v3.0.0 -m "Release 3.0.0"
Correct Answer: git log v1.1.0..v1.2.0
Correct Answer: Bump SemVer via a changelog/conventional commits and create annotated tags from CI on main
Correct Answer: git describe --tags --abbrev=0
Correct Answer: Require PR reviews, status checks, and disallow force pushes
Correct Answer: fix: handle null in user serializer
Correct Answer: Defines default reviewers/approvers for paths
Correct Answer: They reduce review time and risk, and speed feedback loops
Correct Answer: Feature description, test plan, screenshots/logs, risk/rollback
Correct Answer: Use CI to run affected-graph tests and require green checks before merge
Correct Answer: Pair program or conduct pre-PR design review
Correct Answer: Validate input/output, secrets not committed, and dependency changes scanned
Correct Answer: Add a CI warning or soft gate on changed-lines with guidance and examples