react-native : can't push to git because of hprof file
The only answer here didn't work for me, but I found a solution that did.
My offending file was android/java_pid2325.hprof
, but yours obviously may vary. I used git filter-branch
:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch android/java_pid2325.hprof'
Make sure to add *.hprof
to your .gitignore
and push the commit.
Note*-> Make sure to change the name of *.hprof to the same as your local *.hprof
This sounds like a heap profiling output file, which you probably don't want in your repository at all. You'll want to delete it from the entire history and probably add an entry to .gitignore
to ignore *.hprof
. If the file is not in the latest commit, simply deleting it there won't make your repository pushable to GitHub; you'll have to remove the object from the entire history.
If you can easily find the commit which introduced it (try git log -- android/java_pid14920.hprof
), you can do a git rm android/java_pid14920.hprof
and then do git commit --fixup HASH-OF-COMMIT && GIT_SEQUENCE_EDITOR=true git rebase -ir --autosquash HASH-OF-COMMIT^
(note the caret) to rebase out the file.
You can also use a tool like git filter-branch
or bfg
to filter out large objects that you don't want.
Note that doing this will rewrite the history of any intervening commits, changing their object IDs.
@bk2204 answer worked for me.In my case, .hprof files were in android/hprof.
Go to ".gitignore"
Just put this snippet.
android/
*.hprof
- Save .gitignore file.