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?

- 1,744
- 4
- 24
- 53
-
There is no such thing as pull request in git. pull requests are a github thing, not a git thing – gman Dec 28 '20 at 02:59
7 Answers
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

- 759
- 7
- 16
You need to remove file, commit changes and make next push to your branch.
If you want leave file in your branch, but not to merge it to main branch, you can delete it in one commit, then add again in another. Git allows you manually accept certain commits using git-cherry-pick. You can accept each commit except that in which you have added this file again.

- 910
- 4
- 18
- 29
I think you can simply override your project.lock.json with the origin one and commit.

- 17,260
- 17
- 99
- 173
If they are already committed, there is no easy way that I can think of. Probably the easiest way, and a kind of work around, is to move them out the project folder, remove them from your git working copy, recommit so your branch doesn't have the JSON files in them. Then when you merge your JSON files won't go across.

- 11
- 3
-
2Would it not show this change as "file deleted"? If I delete this file altogether and then merge my pull request it would delete this file from the main branch as well, right? – tavier Apr 21 '16 at 08:02
You can checkout master and pull and then rebase your branch against master and rebase master to make sure you've removed it only from your PR but not from the repo so when you merge onto master it will not remove those files but only from your PR.
git checkout master
git pull
git checkout <your-branch>
git rebase master
git push

- 4,046
- 1
- 15
- 31

- 1
First, find out the specific commit that affects that file. Then the below two commands should revert the commits to that file.
git revert <commit>
git push origin <branch name>

- 91
- 4
- copy the files from origin repository. And Overwrite the files in your branch's repository.
- Make a commit.
- Go to pull request's "Files Changed" page, there will be an option to refresh. Or refresh the page manually.

- 884
- 10
- 15