What is git merge?
Why Interviewers Ask This
Interviewers use this question to quickly assess whether a candidate has the foundational knowledge required for Git & GitHub development. It reveals whether you understand the building blocks that more complex concepts rely on.
Answer
git merge integrates changes from one branch into another. To merge: switch to the receiving branch first, then merge the source branch. cd main; git merge feature-login. Types of merges: (1) Fast-forward merge: when the target branch has no new commits since the feature branch diverged, Git simply moves the pointer forward — no merge commit created. Clean linear history. git merge --ff-only feature — only merge if fast-forward is possible; (2) Three-way merge (non-fast-forward): when both branches have diverged, Git finds the common ancestor commit, merges changes from both, and creates a new merge commit with two parents. This preserves the complete history but adds merge commits; (3) Squash merge: git merge --squash feature — combines all feature branch commits into one set of staged changes; you then make one commit. Loses individual feature branch history but keeps the main branch clean. Handle merge conflicts when Git can't auto-merge: resolve conflicts in the files, then git add and git commit.
Pro Tip
Back up your answer with a specific project or situation. Saying 'In my last Git & GitHub project, I used this when...' immediately makes your answer more credible and memorable.