CS FundamentalsModerateAccenture · Infosys · Git interview

You have 2 local commits on main and the remote main has 3 new commits. What does git pull --rebase do?

  1. A. Creates a merge commit joining the two histories
  2. B. Discards your 2 local commits and takes the remote's
  3. C. Fetches and then replays your 2 commits on top of the 3 remote commits, giving them new hashes and a linear history
  4. D. Pushes your 2 commits first and then pulls

Correct answer: C. Fetches and then replays your 2 commits on top of the 3 remote commits, giving them new hashes and a linear history

pull --rebase = fetch + rebase onto the updated upstream. Your commits are re-created (new hashes) after the remote ones, with no merge commit. Since they were unpublished, rewriting them is safe.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic