
I Thought I Understood Git. Then I Actually Learned the Difference Between Rebase and Merge.
I used git rebase long before I actually understood what it does. I picked it up from a senior developer on my first team. The rule was simple: always rebase before you merge, keep the history clean. I followed it. I typed the commands. I never questioned it. Then one day I rebased the wrong branch and rewrote a week of shared history. That was the day I finally sat down and learned what I had been doing. What merge actually does git merge takes two branches and joins them. It creates a new commit — a merge commit — that has two parents: the tip of your branch and the tip of the branch you're merging into. # You're on feature/my-feature git merge main The result is a non-destructive operation. Nothing is rewritten. Your history grows a new node with two parents, and both lines of development are preserved exactly as they happened. A---B---C feature / \ D---E---F---G---H main (merge commit) The upside — it's safe. The downside — if you merge large feature branches frequently, the commit
Continue reading on Dev.to Webdev
Opens in a new tab




