Course lesson

Squash Commits Before they are Pushed with Interactive Rebase

We have created 3 commits that we want to squash together before we push them to github. We can enter an interactive rebase with:

Duration
2 min
Access
Free
Transcript
Retained from source evidence

We have created 3 commits that we want to squash together before we push them to github. We can enter an interactive rebase with:

git rebase -i HEAD~3

and then change pick to squash for the last two commits (we want to squash "down" into the first one).

Then we'll be given the chance to make the commit message for that commit, and once we save the message we'll be left with just a single commit that contains the changes from all three commits.

Terminal
git rebase -i HEAD~3

# Make the changes in interactive rebase
# Make the commit message for that commit, and once we save the message
# we'll be left with just a single commit

✏️ Edit on GitHub