How to remove a file from Git Pull Request

tavier picture tavier · Apr 21, 2016 · Viewed 38.5k times · Source

I have a pull request opened where I have some project.lock.json files which I do not want to merge while merging my branch to main branch. Is there a way to remove thos project.lock.json files from my Pull Request?

Answer

Shiyason picture Shiyason · Feb 23, 2017

Please do let me know if there is a better way of doing this. This is the workaround I have found.

list remote branches

git branch -va

checkout the PR branch

git checkout origin pr_branch

overwrite pr_branch's file with other_branch's file

git checkout other_branch -- ./path/to/file

commit changes

git commit -m "overwrite with other_branch's"

push your changes

git push origin pr_branch