Rebasing the first commit on Git
February 13, 2022
Problem
Let’s suppose you have a repository with the following commit history:
5a998b8 (HEAD -> main) third commit
f318ad8 second commit
a187c18 first commit
By default, when you try to rebase all commits by running:
git rebase -i HEAD~3
The following error message will be shown:
fatal: invalid upstream 'HEAD~3'
Solution
To do that, simply run:
git rebase -i --root