git

Fix "cannot 'squash' without a previous commit" for Git

franzwong

Franz Wong

Posted on May 22, 2020

Fix "cannot 'squash' without a previous commit" for Git

Suppose you create a new codebase and you have only 2 commits. Now you want to combine the 2nd commit to the 1st commit with this command.

git rebase -i HEAD~1

However, Git cannot perform that and it returns an error message like this.

error: cannot 'squash' without a previous commit

For this case, you should try this.

git rebase -i --root
💖 💪 🙅 🚩
franzwong
Franz Wong

Posted on May 22, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related