Delete file from Pull Request on GitHub

坚强是说给别人听的谎言 提交于 2020-01-22 10:26:07

问题


I have make pull request on git (with "xcodeproj/project.pbxproj" file - my fault), so can I delete this file from created Pull Request? Thanks..


回答1:


  • Make a commit that deletes this file and push it.
  • Go to your fork's Github page and click Pull Request again. You will get a message stating that you already have a pull request, and that you can adjust the commit range for it.
  • Include your new commit (with the deletion).

The offending file will still be in the changesets to be merged, mind you, so if it contains sensitive data it's best to close the pull request and wipe out the file from your fork's repository first. Github help describes how to do that.




回答2:


You probably will merge this pull request on master, so you can checkout just this specific file again, from master, on your branch, just type:

git checkout master -- xcodeproj/project.pbxproj
git commit -m "removing a file from PR"
git push origin {YOUR BRANCH}



回答3:


Another solution would be to

  • Locally rewrite your commit(s) by removing the file, using amend or rebase git features
  • Force push your branch toward your GitHub repository

This will update the pull request by only displaying your refreshed commit(s).




回答4:


CAUSION : Will delete local file also. Suitable when you pushed an auto generated file.

git rm <path to file>



回答5:


New approach, since July 2018:

Removing files from a pull request

Previously, if you wanted to use GitHub to remove files from a pull request, you’d need to switch to the pull request branch and look for the individual file to delete it.

Now, if you have write permission, you can click on the ‘trash’ icon for a file right in the pull request’s “Files changed” view to make a commit and remove it.




回答6:


If all you want to do is just remove(delete) the changeset of a file that is already a part of the pull request, currently you can't do that via the web UI. You have to update the file locally and do a git push to the PR.



来源:https://stackoverflow.com/questions/9498201/delete-file-from-pull-request-on-github

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!