DEV Community

Franz Wong
Franz Wong

Posted on

2 1

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

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more