- Edit the Commits: An editor will open showing something like following
pick abc123 feat(client): project init
pick def456 feat(client): only allow pnpm as package manager
pick def456 feat(client): add .nvmrc file to ensure the project runs with the correct Node version
Change pick
to edit
for the commit you want to edit. like following
edit abc123 feat(client): project init
pick def456 feat(client): only allow pnpm as package manager
pick def456 feat(client): add .nvmrc file to ensure the project runs with the correct Node version
save and close the file.
- Amend the file to the picked commit.
Now you're time travelled to the first commit (you can confirm this by
git log --oneline
as you can see only your first commit) add the missed file & amend the commit
git add pnpm-lock.yaml
git commit --amend
save and close the file.
- Finish the rebase use the following command to finish the rebase and come back to the present commits
git rebase --continue
Now your changes are successfully added to the first commit, and your commit history is revised.