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