Adding new commit before the first commit of a branch
Sometimes, while working on a branch, I want to add a new commit before the first commit.
The best way I found until now to do this are the following steps.
- While on the work branch, make an empty commit with
git commit --allow-empty -m "Empty commit"
- Interactively rebase on the branch from which we checked out, move the empty commit to be the first one and choose to
edit
it - While in
edit
of the empty commit make the wanted changes andgit commit --amend
them to the empty commit git rebase --continue
and fix conflicts if needed