- Find the commit hash you want to edit
 
git log 
Start interactive rebase, adjust the number if needed
git rebase -i HEAD~1In the editor, change 'pick' to 'edit' for the commit you want to modify
Save and close the editor
Add the new file
git add path/to/newfile 
- Amend the commit to include the new file
git commit --amend 
Save and close the commit message editor
Continue the rebase
git rebase --continueResolve any conflicts if necessary Force push to the remote repository if needed
git push --force