Search code examples
gitgithub

Remove a file from a Git Pull Request


I have added a local changes to an existing file into my PR by mistake. I want to revert only this file without deleting this file locally. I just want that it doesn't show up in the Pull Request. I don't want to create new branch as many people have commented on other files in this PR.


Solution

  • If you updated a file that already existed and want to remove it from the PR:

    Assume you're working on a branch off of staging, and you PR'd a file named validate_model.py.

    To remove this file from the PR and revert its changes, simply do:

    git checkout staging -- validate_model.py