I have 3 modified files (no new files) in a pull request at the moment.
I would like to remove one of those files from the pull request, so that the pull request only contains changes to two files and leaves the third in its original, untouched state.
I have tried a couple things (checking out the original version of the file, etc...) but it still shows as a changed file in the PR.
Is there a solution to this?
This question is tagged with
~ Asked on 2016-09-12 22:03:25
Switch to the branch from which you created the pull request:
$ git checkout pull-request-branch
Overwrite the modified file(s) with the file in another branch, let's consider it's master:
git checkout origin/master -- src/main/java/HelloWorld.java
Commit and push it to the remote:
git commit -m "Removed a modified file from pull request" git push origin pull-request-branch
~ Answered on 2017-06-04 15:29:37
You would want to amend the commit and then do a force push which will update the branch with the PR.
Here's how I recommend you do this:
git reset --soft HEAD^or if it's a different commit, you would want to replace 'HEAD^' with the commit id)
git commit -a -c ORIG_HEAD
The now that your branch has been updated, the Pull Request will include your changes.
Here's a link to Gits documentation where they have a pretty good example under Undo a commit and redo.
~ Answered on 2016-09-12 23:13:04