Merge: creates a new merge commit that has two parents — the tip of the current branch and the tip of the target branch. The full history of both branches is preserved. The commit graph shows a non-linear history with merge nodes.
Rebase: replays commits from the current branch on top of the target branch one by one. Each commit gets a new SHA (new parent pointer). The result is a linear history as if the work was always done on top of the target. Original commits are orphaned (garbage-collected eventually).
Internally: rebase uses cherry-pick logic — for each commit, it computes the diff (patch) and applies it to the new base, creating a new commit object.
How do you resolve merge conflicts?
Show the answer
git merge — Git marks conflicting files with <<<<<<<, =======, >>>>>>> markers.
Open the conflicting files and decide which changes to keep (or combine both).
Remove the conflict markers.
git add <resolved_file> to mark it resolved.
git commit to complete the merge.
Tools: git mergetool (opens vimdiff, IntelliJ, VS Code), git diff --conflict to review, git checkout --ours/--theirs to take one side wholesale.
For complex conflicts, git log --merge shows the commits that introduced the conflict.
Difference between git pull, git fetch, and git clone?
Show the answer
Command
What it does
git clone
Creates a full local copy of a remote repository (all branches, history, objects). One-time operation.
git fetch
Downloads new objects and refs from the remote into FETCH_HEAD and remote-tracking branches (e.g., origin/main) but does NOT update your working branch. Safe to run anytime.
git pull
git fetch + git merge (or git rebase with --rebase flag). Updates your working branch. Can introduce unexpected merge commits.
Best practice: Use git fetch + review + git merge/git rebase for explicit control.
27 more in the member app, with practice sets and your own marks. Join free