'React Native gradle executionHistory.bin too big

I've recently upgraded my react-native app to version 0.60.5, as to fulfil App Store requirement of 64-bit app, but I've noticed that the executionHistory.bin file inside android/.gradle/x.x.x/executionHistory got really big, going from ~6Mb, to ~100Mb, which is a real pain as GitHub won't allow files larger than 100Mb to be uploaded. I searched a way to clean the file, delete it and recreate it but really haven't found much. I want to know how to solve this issue, if I screw up upgrading my rn version or something.

Specs:

OS:
macOS Catalina
version: 10.15.1

React-Native: 0.60.5



Solution 1:[1]

The .gradle directory should be added to the .gitignore. There is no need to have this in version control as it is just used to store some build cache and various things that get re-generated when gradle builds.

My suggestion... Delete the .gradle directory locally and from your git repo (it will regenerate next time you build android). Then add it to your .gitignore.

See here for the recommended ignore file for react-native (created by react-native): https://github.com/facebook/react-native/blob/master/template/_gitignore

Solution 2:[2]

Just in case you are having this issue AFTER committing and pushing...

I just realized I had this issue when cloning a large repo (~470MB).

I used https://github.com/newren/git-filter-repo to inspect large objects that were bloating the git history, and found executionHistory.bin, node_modules and all kinds of other shit that should never have been checked in the first place.

I made a list of files a directories to delete from history and added them in a file to_delete.txt, in the directory one level above my repo:

# Files and directories to delete

android/.gradle
node_modules
...

And then:

git filter-repo --invert-paths --paths-from-file ../to_delete.txt --force

Note the --force option, because I was getting wrong warnings about my repo not being a fresh clone.

After this, my repo size is just above 6MB, which makes much more sense for the small-ish project that it is ???

Hope this helps!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 samzmann