I forgot to add a file to a commit that I have already pushed and created a pull request for. The pull request got rejected (because of other reasons). I now want to add the missing file to the original commit and then perform the requested changes in a new commit before issuing a new pull request. However, a git rebase
to squash the commit of the missing file into the old one changes the hash of the commit which leads to strange effects on GitHub. Is there a way to do what I am trying or do I have to let the missing file in its own commit?
I am the only one using my repository. Pull requests are the only reference to other users.
Short answer - no, you can't even change the message of a commit without changing its hash, much less adding a file.
Generally, if you have pushed a change to a remote (that others depend on) you don't change the history by doing things like amending and squashing commits.
The ideal approach might be for you to add the file in a separate commit and have that included in the pull request as well.