I want to sync my local changes to the GitHub master repo online. I originally had a file over 100 MB but since added it to the .gitignore
file. I moved the large file to another, untracked non-Git folder.
$ git status
On branch master
Your branch is ahead of 'master/master' by 42 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
When I run git push,
$ git push
Enumerating objects: 216, done.
Counting objects: 100% (215/215), done.
Delta compression using up to 8 threads
Compressing objects: 100% (185/185), done.
Writing objects: 100% (201/201), 85.26 MiB | 4.67 MiB/s, done.
Total 201 (delta 73), reused 4 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (73/73), completed with 7 local objects.
remote: warning: File data/SU_COMP_LT.csv is 78.18 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: error: Trace: 59a9f7d74f43667d95618d6bc07346491424a287ecab333c99fa78e5714e39da
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File data/SU_COMP_LT.csv is 117.74 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/path.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/path.git'
I tried git reset file_name
and git ls-tree -r master --name-only
and the big file isn’t tracked. How do I sync the local repo to the GitHub repo?
2
Answers
I had to use BFG Repo-Cleaner and their website. Using GitBash,
Then finally, I confirmed everything,
Your problem is that
.gitignore
have no effect on items that have previously been tracked.To fix this run (in VS Code you should be able to do this from the console itself or you can use something like Git Bash):
In your case
file_name
would be the file that is over 100MB.This will unstage the file and keep it but should now ignore it if it is added to the
.gitignore
. Hope that helps