Cloud & DevOps5 min read10 interview questions
Git branches and pull requests
How teams change the same code without stepping on each other.
In one sentenceA branch is your own copy of the code to work on safely. A pull request asks the team to review it and merge it back.
Think of it like thisIt is like drafting your edits on a photocopy of a shared document, then asking colleagues to approve them before they go into the master copy.
The big picture
Tap any step to see where to use it, how to use it and an example result.
Branches keep work separate
The main branch holds the code that works. You create a new branch for each task, change things freely, and main stays safe until you are ready.
Commits are saved steps
A commit saves a snapshot with a message. Small commits with clear messages make it easy to see what changed and to undo one thing without losing the rest.
Pull requests are conversations
A pull request shows your changes beside the old code, lets reviewers comment, and runs automatic checks. Merging brings the branch into main when everyone is happy.
Common mistakes
- Making huge pull requests nobody can review.
- Writing commit messages like "fix" or "stuff".
- Working for weeks on a branch without pulling in the latest main.
Quick recap
- One branch per task
- Small commits with clear messages
- Pull requests are for review and checks
- Merge only when checks pass
Try it yourself
Make a practice repository, create a branch, change a file, push it and open a pull request to merge it into main.
Top 10 interview questions
Ordered from basic to advanced. Try answering out loud first, then open the answer.
What is Git?Basic
A distributed version control system that records the history of changes to your files, so you can go back, compare and work with others without overwriting each other.
What is a branch?Basic
A separate line of work. You can make changes on a branch without touching the main code, then merge them back when ready.
What is a pull request?Basic
A request to merge your branch into another, usually main. It gives teammates a place to review the changes, discuss them and run automated checks.
What is the difference between git fetch and git pull?Basic
Fetch downloads new changes but does not change your files. Pull is fetch followed by a merge (or rebase) into your current branch.
What is the difference between merge and rebase?Intermediate
Merge joins two histories with a merge commit and keeps the true history. Rebase replays your commits on top of another branch for a straight, cleaner history, but it rewrites commits, so avoid it on shared branches.
What is a merge conflict and how do you resolve it?Intermediate
It happens when two branches change the same lines. Git marks the conflict in the file, you choose or combine the right content, remove the markers, stage the file and complete the merge.
What does squash merge do?Intermediate
Combines all commits of a pull request into a single commit on the target branch, keeping main's history short and readable.
How do you undo a commit?Intermediate
If it is not pushed, git reset can move back. If it is shared, use git revert, which adds a new commit that cancels the old one without rewriting history.
Compare common branching strategies: trunk-based development and Git Flow.Advanced
Trunk-based development uses short-lived branches merged to main many times a day, often with feature flags, and suits continuous delivery. Git Flow uses long-lived develop and release branches, which adds ceremony and delays integration.
How do you find which commit introduced a bug?Advanced
Use git bisect: mark a good and a bad commit and Git does a binary search through the history, so you find the culprit in a few steps. Git blame also shows who last changed each line.
Guides are simplified on purpose. Tool names and details change, so check the official documentation before relying on a detail.