PrepPilotPractise free

Git & Collaboration interview questions

Branching, merge vs rebase, conflicts, history recovery, code review

16 questions · git rebase · updated November 2026

Practise these as flashcards. One or two lines each; the ones you miss come back first.

Start free

Core questions

What is a Git commit?

A Git commit is a snapshot of your project's files at a specific point in time. It records changes and includes a message describing what was changed.

How do you create a new branch and switch to it?

You can create and switch to a new branch with git checkout -b branch-name. This creates the branch and moves HEAD to it.

What does HEAD represent in Git?

HEAD is a pointer to the current branch and commit you have checked out. It's where new commits will be added.

How do you fetch changes from a remote repository?

You use git fetch origin to update your local tracking branches with changes from the remote repository.

Intermediate questions

When would you use merge vs rebase?

I use merge when integrating shared branches, like merging a feature branch into main, to preserve history. I use rebase for local feature branches to keep history linear and avoid unnecessary merge commits, but only when the branch hasn’t been shared.

How do you resolve a merge conflict?

When Git marks a conflict, I open the affected files, look for the conflict markers, and manually edit the code to resolve the differences. After resolving, I stage the changes and complete the merge with git commit.

Describe trunk-based development and its benefits.

Trunk-based development uses a single main branch with short-lived feature branches. It encourages frequent integration, reduces merge conflicts, and speeds up delivery by keeping everyone close to the latest code.

What is the difference between git reset and git revert?

git reset moves HEAD and can change your working directory and index, potentially removing commits. git revert creates a new commit that undoes the changes from a previous commit, which is safer for shared history.

How would you recover a commit that was accidentally deleted?

I would use git reflog to find the commit hash and then use git checkout or git cherry-pick to restore it to my branch.

What is git stash used for?

Git stash temporarily saves changes that aren’t ready to commit, so you can switch branches or work on something else without losing your progress. You can later apply the stashed changes with git stash pop.

How do you cherry-pick a commit?

I use git cherry-pick <commit-hash> to apply a specific commit from another branch onto my current branch.

Senior questions

How would you debug a regression using git bisect?

I start with git bisect start, mark the current commit as bad, and a known good commit. Git checks out commits between them, and I test each one, marking them as good or bad. Git narrows down the commit that introduced the regression.

What are the risks of rebasing shared branches?

See the answer in the app, free

How do you ensure secrets are not committed to Git history?

See the answer in the app, free

How do you enforce branch protection and signed commits in a team?

See the answer in the app, free

Describe your approach to code review in pull requests.

See the answer in the app, free

More Developer fundamentals topics