react-native :由于 hprof 文件,无法推送到 git

Fee*_*htz 21 android github hprof react-native react-native-android

我想将我的项目推送到 github,但是我注意到在 android 文件夹中有一个名为java_pid14920.hprof的文件,导致大约 300MB

remote: error: File android/java_pid14920.hprof is 301.75 MB; this exceeds GitHub's file size limit of 100.00 MB

我想知道删除这个文件是否安全?

bk2*_*204 31

这听起来像是一个堆分析输出文件,您可能根本不希望在您的存储库中使用它。您可能希望从整个历史记录中删除它,并可能添加一个条目.gitignore来忽略*.hprof。如果该文件不在最新提交中,只需将其删除不会使您的存储库可推送到 GitHub;您必须从整个历史记录中删除该对象。

如果您可以轻松找到引入它的提交( try git log -- android/java_pid14920.hprof),您可以执行 agit rm android/java_pid14920.hprof然后执行git commit --fixup HASH-OF-COMMIT && GIT_SEQUENCE_EDITOR=true git rebase -ir --autosquash HASH-OF-COMMIT^(注意插入符号)以重新设置文件。

您还可以使用类似git filter-branch或的工具bfg过滤掉您不想要的大对象。

请注意,这样做将重写任何干预提交的历史记录,更改它们的对象 ID。


Dav*_*ggs 28

这里唯一的答案对我不起作用,但我找到了一个解决方案。

我的违规文件是android/java_pid2325.hprof,但你的显然可能会有所不同。我用过git filter-branch

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch android/java_pid2325.hprof'

确保添加*.hprof到您的.gitignore并推送提交。

注意*-> 确保将*.hprof的名称更改为与您本地的 *.hprof 相同

  • 非常感谢您,这是对我有用的最佳答案。 (3认同)

小智 8

我运行了这个命令。它适用于 Windows 10

git filter-branch -f --index-filter "git rm --cached --ignore-unmatch android/java_pid10213.hprof"
Run Code Online (Sandbox Code Playgroud)
  • 使用代替


小智 5

@bk2204 答案对我有用。就我而言,.hprof 文件在 android/hprof 中。

  1. 转到“.gitignore”

  2. 把这个片段放上就行了。

安卓/

*.hprof

  1. 保存 .gitignore 文件。


小智 5

我提交了两个 hpprof 文件;所以我只是运行这个命令,文件已成功删除。

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch android/java_pid21295.hprof android/java_pid16516.hprof'
Run Code Online (Sandbox Code Playgroud)