Compare Trunk-Based Development with the Gitflow workflow: which is better suited for Continuous Deployment and why?
Senior
How do you stash only specific files or include untracked files when stashing?
Mid
How does git stash work internally, and where does the data go when you "pop" it?
Senior
What are the risks of keeping a feature branch open for several weeks, and how does this impact the eventual merge process?
Mid
What is the difference between git stash pop and git stash apply, and when would you choose one over the other?
Junior
What is the forking workflow, and how does it differ from a shared-repository feature-branch workflow?
Mid
Navigating & Inspecting History
Explain how git bisect works: how does it use binary search to find a bug, and what is the requirement for the commit history for it to be effective?
Mid
Explain the difference between git checkout, git switch, and git restore.
Mid
How can you filter and format git log output to inspect history effectively?
Junior
How does git blame work, and what kind of question does it help you answer?
Junior
What does git rm --cached do, and when would you use it?
Mid
Fundamentals & Architecture
Explain the 'Three Trees' or 'Three States' model in Git: what is the conceptual difference between the Working Directory, the Staging Area (Index), and the Repository?
Junior
Explain the difference between "Plumbing" and "Porcelain" commands in Git.
Senior
What is the difference between a tracked, untracked, and ignored file in Git?
Junior
What is the fundamental architectural difference between Git and a centralized VCS like SVN or Perforce, and why does Git allow you to work offline?
Mid
What is the point of version control, and what problems does it solve for a development team?
Junior
What is the purpose of .gitignore vs. .gitattributes?
Junior
What is the purpose of the .git directory, and what would happen if you deleted it?
Junior
Why does Git have a staging area instead of committing directly from the working directory?
Junior
Remotes Fetch Push & Clone
Explain the difference between an "Upstream" branch and a "Tracking" branch.
Mid
How do you migrate a Git repository to a new server using only Git commands?
Mid
What does git push -u (set upstream) do, and how does it change future push/pull behavior?
Junior
What does it mean to 'prune' a remote, and why might your local list of remote branches still show branches that were deleted on the server?
Mid
What happens under the hood when you run git clone?
Junior
What is a 'remote-tracking branch' like origin/main, and how is it different from your local main branch?
Mid
What is a "Refspec," and how does Git use it during a fetch or push operation?
Senior
What is git pull --rebase, and why might a team prefer it over a default pull?
Mid
What is the difference between git fetch and git pull, and why is git pull often described as a 'shortcut'?
Junior
What is the difference between git push --force and git push --force-with-lease, and why is the latter preferred in a professional environment?
Mid
What is the difference between origin and upstream when working with multiple remotes, and how is this used in a forking workflow?
Mid
Rebasing & History Rewriting
Explain the difference between git merge and git rebase, and when you would choose one over the other.
Mid
How does git cherry-pick work, and in what specific scenario is it better than a merge?
Mid
How would you permanently remove a sensitive file (like a leaked secret) from the entire Git history, and what tools would you use?
Senior
What does rebase --onto let you do that a normal rebase cannot?
Senior
What happens to commit hashes during a rebase?
Mid
What is an "Interactive Rebase," and when would you use "Squash" vs. "Fixup"?
Mid
What is git rerere and when is it useful?
Senior
What is rebase autosquash, and how does it work together with fixup/squash commits?
Senior
What is the "Golden Rule" of rebasing, and what happens if you break it?
Mid
Undoing & Recovery
Explain the difference between git reset --soft, --mixed, and --hard, and what happens to the staging area and working directory in each case?
Mid
If you are in the middle of a complex merge or rebase and realize you've made a mistake, how do you return the repository to its exact state before the operation started?
Mid
What is git reflog expire, and how long are unreachable commits kept before they can be garbage collected?
Senior
What is the difference between git clean and git reset?
Mid
What is the difference between git reset and git revert, and which one is safer for public history and why?
Mid
What is the reflog, how does it differ from git log, and how can it be used to recover a 'deleted' branch?
Mid
Commits & Staging
Explain the difference between the "Author" and the "Committer" in a Git commit object.
Mid
How do you create an empty commit, and in what situations is that useful?
Mid
How does the index/staging area let you build up a commit with only part of your changes, e.g. with git add -p?
Mid
What is a signed commit or signed tag, and why would a team require GPG/SSH signing?
Mid
What is the difference between git commit --amend and a standard commit?
Junior
What is the difference between git status and git diff in terms of the three areas?
Mid
What makes a good commit message, and why does Git separate the summary line from the body?
Junior
Object Model & Internals
Explain the Git object model. What are the four main types of objects?
Mid
How does Git compute object IDs (hashes)?
Senior
How does Git ensure data integrity?
Mid
How does Git store a commit internally: does it store diffs or snapshots?
Mid
How does Git’s content-addressable storage work, and what role does the SHA-1 hash play?
Senior
How would you manually create a commit using only plumbing commands?
Senior
What are dangling objects, and how do git fsck and the reflog relate to them?
Senior
What does HEAD point to in Git, and what is a symbolic ref?
Mid
What exactly is a 'ref' in Git, and where are refs stored inside the .git directory?
Mid
What exactly is stored inside a Git commit object?
Mid
What happens inside the .git/objects/ directory before and after a git gc?
Senior
What is the commit DAG, and how do parent pointers form the shape of your history?
Mid
What is the difference between a blob object and a tree object?
Mid
What is the difference between a loose object and a packfile, and why does Git pack objects?
Senior
What is the SHA-1 to SHA-256 transition in Git about, and why is it happening?
Senior
Why does Git use SHA-1 (or SHA-256) hashes for commits instead of simple incrementing version numbers?
Mid
Large Repos Submodules & Performance
From a Git performance perspective, what are the challenges of a very large Monorepo, and how does Git handle them (e.g. sparse checkout, scalar)?
Senior
How does Git handle large binary files, and what is Git LFS (Large File Storage)?
Mid
What are "Git Submodules," and why are they often considered difficult to manage?
Mid
What does git gc actually do, and what is the role of prune and repack?
Senior
What does the git maintenance command (or Scalar) provide for keeping large repositories fast?
Senior
What is a Git Submodule, and why might you use a submodule instead of just copying the code into your repository?
Mid
What is a Sparse Checkout and when is it useful?
Mid
What is git worktree, and how does it allow you to work on two branches simultaneously without two clones?
Mid
What is the difference between a "Shallow Clone" and a "Partial Clone"?
Senior
What is the difference between a Git submodule and a subtree, and what are the trade-offs?
Senior
Merging & Conflicts
How do you handle a merge conflict conceptually?
Junior
How do you revert a merge commit, and why is it trickier than reverting a normal commit?
Senior
How does a three-way merge determine the merge base, and why is it needed?
Mid
What are the different merge strategies in Git (ort/recursive, ours, octopus), and when does each apply?
Senior
What are the trade-offs of using git merge --no-ff?
Mid
What is a 'Fast-Forward' merge and when is it not possible?
Junior
What is a 'Squash and Merge' and why would a team choose it?
Mid
What is a "Merge Conflict," and how does Git determine that a conflict has occurred?
Junior
What is an 'Octopus Merge' and when would you use it?
Senior
What is the difference between a 'Fast-forward' merge and a 'Three-way' (recursive/ort) merge, and when will Git be unable to perform a fast-forward?
Mid
What is the difference between git merge --no-ff and git merge --squash, and when would a team prefer one over the other?
Mid
What tools does Git give you to resolve a merge conflict, such as choosing ours/theirs or using a mergetool?
Mid
Branches Refs & Tags
How do you push tags to a remote, and why aren't tags pushed automatically with a normal push?
Junior
In Git's internal model, what actually is a 'branch', and how is it different from a tag?
Mid
What are the trade-offs between tags and branches for marking releases?
Mid
What does git describe do, and how does it derive a human-readable name from tags?
Mid
What is a "Detached HEAD" state? How do you end up in one, and how do you fix it?
Mid
What is git grep, and how does it differ from a normal file search?
Junior
What is the annotated tag object, and how does it differ from the other Git object types?
Mid
What is the difference between a lightweight tag and an annotated tag, and when should you use each?
Junior
Configuration & Tooling
How does Git handle line-ending normalization, and what do core.autocrlf and .gitattributes settings do?
Mid
What are Git Hooks? Give an example of a client-side hook vs a server-side hook and what they might be used for.
Mid
What are the different levels of git config (system, global, local), and how do they override each other?
Junior
What is a credential helper in Git, and what problem does it solve?
Mid
What is a Git alias, and why would you set one up?
Junior
Top 103 Git Interview Questions And Answers 2025 | TechPrep