Sitemap
Jeffrey Rennie

Jeffrey Rennie

git rebase or git merge? Neither.

2 min readJun 19, 2025

--

Press enter or click to view image in full size

I just watched some people argue about this, and I didn’t hear anyone describe my favorite solution, so I’ll describe it here. It leaves a perfect trail of breadcrumbs so if I make mistake, I can always rollback. Hopefully, it saves you some time and pain.

Get Jeffrey Rennie’s stories in your inbox

Join Medium for free to get updates from this writer.

In this scenario, I’ve been working in my feature branch for two weeks. Of course, lots of changes have been committed to the main branch while I’ve been working in my feature branch. Now it’s time to pull changes from main.

> git status
On branch feature
nothing to commit, working tree clean
> git checkout main
> git pull
> git checkout -b feature2
> git merge --squash feature

And then I resume my work in the feature2 branch.

Why this is better than rebase or merge.

  • The git history is perfectly linear, thanks to--squash.
  • Changes are never overwritten or lost.
  • Resolving conflicts the wrong way can be undone later.

And yes, this is a serious flaw in git.

I hate the fact that git provides at least 3 ways to do the most common task of any source control system: pull down recent changes from the main branch. The git command line is hostile to humans. I haven’t found anything better, though.

--

--