Join waitlist
GeneralCommunity question

git merge vs rebase - which one rewrites history

Asked by Divya Krishnan 1 month ago 2 answers 6 votes

Got this wrong in a quiz. Rebase rewrites history right? merge just adds a merge commit?

2 answers

Vikram Singh1 month agoMost voted5

Yes. Rebase replays your commits on top of the other branch, they get new hashes. Merge keeps both histories and adds a merge commit.

Rule: don't rebase a branch others have already pulled. Rebasing your own feature branch before a PR is fine.

Nikhil Choudhary1 month ago2

also asked a lot: fetch vs pull, reset vs revert

Related questions

Go deeper

Want the full explanation, not just an answer?

Structured lessons on DSA, core CS, Java and interview skills, each ending in a quiz so you know it stuck.