Muhammad Umer Muhammad Umer - 10 months ago 51
Git Question

Remove deleted files from github pull request?

I deleted some files locally that were machine generated, but also being tracked. After deletion some time ago, I made multiple commits and made a pull request.

However, contributors want me to remove that deletion part from the commit.

How can I fix that?

Most times I get this error: (git rm, git checkout etc)

error: pathspec 'filepath' did not match any file(s) known to git.

File was deleted locally.


Find the commit where you deleted the file:

git log -n1 -- path/to/file

Restore the file from one commit before the one that deleted it:

git checkout SHA1~1 -- path/to/file

Repeat for each removed file you want to restore.

Commit, and push to the branch to update the Pull Request (adding one commit).