How to remove a file from a Git Pull request

I have a transfer request that opens when I have several project.lock.json files that I don’t want to merge, merging my branch with the main branch. Is there a way to remove thos project.lock.json files from my Pull request?

+5
source share
5 answers

You need to delete the file, commit the changes and make the next click on your branch.

If you want to leave the file in your branch, but not merge it into the main branch, you can delete it in one commit and then add it back to another. Git allows you to manually accept specific commits using git -cherry-pick. You can accept every message except the one in which you added this file again.

+1
source

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

list of remote branches

 git branch -va 

check PR branch

 git checkout origin pr_branch 

overwrite pr_branch file with other_branch 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 
+2
source

If they are already perfect, there is no easy way that I can think of. Probably the easiest way and kind of work is to get them out of the project folder, delete them from the working copy of git, confirm that there are no JSON files in your branch. Then when you combine the JSON files, you will not go over.

0
source

I think you can just redefine your .lock.json project with the source code and commit.

0
source

You can check the master and pull, and then reinstall your branch against the master and reinstall the master to make sure that you deleted it only from your PR, but not from the repo, so when you merged with the master, it will not delete these files, but only from your PR.

 git checkout master git pull git checkout <your-branch> git rebase master git push 
0
source

Source: https://habr.com/ru/post/1247586/


All Articles