0

I am starting up a new React Native project, and I have gone through many steps to push my current branch. I have already converted over to SSH from https, already run git config --global http.postBuffer 524288000, pushed a clone of master successfully (no proxy issues or firewall problems), and updated my .gitignore to be more encompassing of files I dont need to upload to Github. I am afraid there is something too large causing my push to hang while writing objects.

I write: git push -u origin branchName

My terminal responds with:

Enumerating objects: 240, done.
Counting objects: 100% (240/240), done.
Delta compression using up to 16 threads
Compressing objects: 100% (131/131), done.
Writing objects:  61% (131/213), 99.58 MiB | 725.00 KiB/s

The writing objects climbs to 61% and then sits there, the MiB continues to climb but never does anything but continue to grow.

Is there a way to see file sizes in git or see the current object being written to Github using push? I am afraid something in my android or ios folders is causing this problem. I have also already cleared the git cache before trying to add the files and push. Any help is greatly appreciated.

Lastly, here is my .gitignore:

# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore
!debug.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
  • `the MiB continues to climb but never does anything but continue to grow` What happens when it finishes growing? Is it possible you just have a large amount of data to push and it will eventually finish? – xdhmoore Feb 15 '21 at 18:43
  • @xdhmoore Possibly? My Mac just crashed, but I was over 500mb and it made it to 62% and just continued going. Is this common? I don't believe I have run into this before... – Christopher Frydryck Feb 15 '21 at 18:47
  • Also, idk if this is helpful, but note that adding files to your `.gitignore` file doesn't remove them from tracking (you have to explicitly remove them), and removing them from tracking doesn't remove them from your history. If you have large files in your history and you have never pushed them before I think they will get pushed regardless of if you have removed them. – xdhmoore Feb 15 '21 at 18:48
  • I don't know. 500mb does seem like a lot. Maybe you have some large files either being tracked still or in your history. There are probably ways to cut out old commits with too large files, but someone else would have to help with that... – xdhmoore Feb 15 '21 at 18:51
  • Update: Gone an error: ` ... remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com. remote: error: Trace: c301f81b374840309474762fb422ccab6fb2dffe4b2921f909da260e82c39368 ... remote: error: File android/java_pid57505.hprof is 666.93 MB; this exceeds GitHub's file size limit of 100.00 MB ` There are multiple of thsoe java pid's that are causing errors. They are generated by react-native for android. I deleted them from the project, but how would I remove them from git? – Christopher Frydryck Feb 15 '21 at 18:53
  • These look relevant: https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository – xdhmoore Feb 15 '21 at 18:55
  • 1
    https://stackoverflow.com/questions/10622179/how-to-find-identify-large-commits-in-git-history – xdhmoore Feb 15 '21 at 18:55
  • Using `git rm --cached ` + using `.gitignore` will remove the file from tracking for future commits. The above questions deal with deleting from history. – xdhmoore Feb 15 '21 at 18:58
  • When I run `git rm --cached android/java_pid28629.hprof` I get an error of `fatal: pathspec 'android/java_pid28629.hprof' did not match any files` – Christopher Frydryck Feb 15 '21 at 19:06
  • Does that file exist? If it doesn't exist it's not being tracked, at least I don't think. – xdhmoore Feb 15 '21 at 19:15
  • I removed it in VSCode, but not in git rm. But if I run this in my terminal: `git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | sed -n 's/^blob //p' | sort --numeric-sort --key=2 | cut -c 1-12,41- | $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest` I get: `...0bb28aed5133 608MiB android/java_pid63813.hprof ad08aaa9355d 638MiB android/java_pid81410.hprof ea727402030c 667MiB android/java_pid57505.hprof` – Christopher Frydryck Feb 15 '21 at 19:20
  • Also if I run `git ls-tree --full-tree --name-only -r HEAD` The files are not there. – Christopher Frydryck Feb 15 '21 at 19:27

1 Answers1

0

Solved this! What you do is first run:

git rev-list --objects --all |   git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' |   sed -n 's/^blob //p' |   sort --numeric-sort --key=2 |   cut -c 1-12,41- |   $(command -v gnumfmt || echo numfmt) --field=2 --to=iec-i --suffix=B --padding=7 --round=nearest

to get a list of files in your cache for git.

Then for any file that comes back you want to go, run:

git filter-branch -f  --tree-filter 'rm -rf android/java_pid63813.hprof /file/path/1 /file/path/2 ...etc' HEAD

Once that is clean, push and it should work!

Mostafa Norzade
  • 1,578
  • 5
  • 24
  • 40
  • Please cite your source! Looks like https://stackoverflow.com/a/42544963/4541045 – ti7 Feb 15 '21 at 21:39