HomebaseWorks

Git interview questions

Git questions that come up in developer and DevOps interviews, with answers that show how you would work in a team.

EWritten by the HomebaseWorks editorial team · reviewed 26 Oct 2026
1
What is the difference between merge and rebase, and when would you use each?

Merge joins two branches and keeps the history as it happened, adding a merge commit when both sides have new work. Rebase replays my commits on top of another branch, giving a straight history but new commit hashes. I rebase my own local branch before opening a pull request and use merge for anything shared.

2
How do you undo a commit that is already pushed to main?

I use git revert with that commit's hash, which adds a new commit reversing it, and then push. This keeps history consistent for everyone who already pulled. I would only reset and force-push if the team agreed, because it rewrites shared history.

3
Walk me through resolving a merge conflict.

I run git status to see the conflicted files, open each one and decide the correct content between the conflict markers, sometimes combining both sides. Then I remove the markers, run the tests, stage the files with git add and commit. If I am unsure about the other change, I ask its author before choosing.

Advertisement
4
What is the difference between git fetch and git pull?

fetch downloads new commits from the remote and updates branches like origin/main without touching my current branch. pull does a fetch and then merges or rebases into my branch. I use fetch when I want to look at what changed before integrating it.

5
What does git stash do and when have you used it?

stash saves my uncommitted changes and gives me a clean working directory. For example, if I am halfway through a feature and a production bug comes in, I stash, switch to a fix branch, finish the fix, then switch back and run git stash pop.

6
Describe the pull request workflow you have used.

I create a branch from an updated main, commit small focused changes and push the branch with -u. I open a pull request describing what changed and how to test it, respond to review comments by pushing more commits to the same branch, and merge only after approval and passing checks. Then I delete the branch.

Practise out loud. Say each answer once as written, then again in your own words with your own number or story.

Have a number ready. "My Git score is at benchmark on a timed test" is a stronger answer than "I am good at it". Take the test and quote the result.

Advertisement
Continue with Git4 lessons · 1 interview set · 1 test · 1 certificate
Not tested

More in Cloud and DevOps