AndoKay
AndoKay

Reputation: 57

Delete files from collaborators pull request on github

I am working a project with a few other people where I am in charge of reviewing and approving pull requests. (We all push code directly to the repo, no forks involved). A teammate just pushed a very large commit where he changed 15 files. For 5 of those I was unhappy with the changes. I don't want these files merged to master but I want the other 10 to be merged.

Is there any way I can delete these 5 files from the pull request and merge the other 10? If I did do that, what should that teammate do, since he already has committed all the changes on his local machine?

Upvotes: 1

Views: 135

Answers (2)

Nitsan Avni
Nitsan Avni

Reputation: 841

The practice I am familiar with is that the original creator of the PR should be the one making the required changes for it to be approved by the reviewers; To me, this seems a better solution in the long run, as each developer will understand better what is expected of him and will improve the team's productivity by reducing the need of such changes in the first place.

Upvotes: 1

Chris Dodd
Chris Dodd

Reputation: 126328

Assuming the PR is a single commit, not multiple commits:

$ git checkout -b new-branch branch-with-change
$ git checkout HEAD^  ...5 files to not include...
$ git commit --amend

You should now have a new branch with a single change with just the 10 files you want to keep and not the 5 other ones. Push that and create a new PR

If the original PR has multiple commits and you want to keep that structure (not squash them all into one), you'll need to do something more complex, with cherry-picking and then modifying each commit, or with rebase -i

Upvotes: 2

Related Questions