skip to Main Content

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


  1. Chosen as BEST ANSWER

    I had to use BFG Repo-Cleaner and their website. Using GitBash,

    $ cd your_local_git_directory
    $ git clone --mirror https://github.com/your_online_git_directory
    $ java -jar C:/path_to_the_bfg_jar_file/bfg-1.13.2.jar --no-blob-protection --delete-files big_file_name.csv
    $ git reflog expire --expire=now --all && git gc --prune=now --aggressive
    $ git push --force
    

    Then finally, I confirmed everything,

    $ git status
    On branch master
    Your branch is up to date with 'master/master'.
    
    nothing to commit, working tree clean
    

  2. 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):

    git reset file_name
    

    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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search