简体   繁体   English

从多个提交中删除同一个文件,使其不在 PR 中

[英]Removing the same file from multiple commits so that it's not in the PR

I use a JS framework that builds a large bundle file.我使用构建大型捆绑文件的 JS 框架。 For testing purposes, I built and committed the bundle so that I could test the changes on a test server.出于测试目的,我构建并提交了捆绑包,以便我可以在测试服务器上测试更改。 I have a handful of commits that include this bundle, main.js , in it but my manager prefers not to merge the bundles in. When creating the PR, how can I exclude this file.我有一些提交包含这个包main.js ,但我的经理不喜欢将包合并进去。创建 PR 时,我如何排除这个文件。

I don't want to delete it because it exists on master .我不想删除它,因为它存在于master上。 But I want to act it if I never added that file change in all of the commits但如果我从未在所有提交中添加该文件更改,我想采取行动

I understood the following: file main.js exists on master , and if you had followed the guidelines, it would never have been modified it on your branch.我理解以下内容:文件main.js存在于master上,如果您遵循指南,它永远不会在您的分支上被修改。
You would like to have your PR not mention file main.js as a modified file.您希望您的 PR 不提及文件main.js作为修改后的文件。


If this is indeed what you are looking for: just restore file main.js to the content it had in master , when your branch forked:如果这确实是您正在寻找的:当您的分支分叉时,只需将文件main.js恢复到它在master中的内容:

# find the merge base which github will use for your PR :
git merge-base master my/branch

# use the sha1 above to restore main.js :
git checkout <merge-base> -- main.js
git commit
git push

File main.js should not appear as modified in your PR.文件main.js不应在您的 PR 中显示为已修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM