Member-only story

[git] Combine Two Commits into One Using git rebase -i fixup and squash

A step-by-step tutorial for the beginners of git

Penny N.
5 min readDec 23, 2021
Photo by Yancy Min on Unsplash

I found that the biggest barrier that hinders me from learning git is git editor, and I believe lots of people are struggling to learn git like I used to be.

You can find tons of articles that teach you how to combine two commits on the internet, but none of them provides a very clear step-by-step instruction on how to do it including how to use git editor. They just assume you know it and skip the details (that is also because people might use different editors). So this article is for muggles like me who need a detailed tutorial but couldn't find one.

My default editor is vi. In the following examples, I will demonstrate those git commands using vi editor.

git rebase -i

In our local repository, we have 2 commits:

MainViewController: update to support dark modeCustom Cell : update to support dark mode

Since they are both modified to support dark mode, we would like to combine them into one.

--

--

Penny N.
Penny N.

Written by Penny N.

A passionate self-taught  iOS developer. Write to record my learning and share the knowledge

No responses yet