sunmingtao / sample-code

3 stars 4 forks source link

Github doesn't allow push even if the large file has been deleted #273

Closed sunmingtao closed 3 years ago

sunmingtao commented 3 years ago
mingtao-nba (main)\ =>git push
....
remote: error: File nba/src/main/resources/nba_players_game_stats.csv is 193.72 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/sunmingtao/soccer-bet.git
 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/sunmingtao/soccer-bet.git'

Delete the large file, commit, still doesn't allow push. Same error

sunmingtao commented 3 years ago
git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch nba/src/main/resources/nba_players_game_stats.csv' HEAD
git pull origin main --allow-unrelated-histories
git push

Note the first git filter-branch ... command is a dangerous operation, which might cause problems for shared repository. Consider other options in https://stackoverflow.com/questions/19573031/cant-push-to-github-because-of-large-file-which-i-already-deleted