GitHub
large file issue
git troubleshooting
version control
push error

Can't push to GitHub because of large file which I already deleted

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

When working with Git repositories and especially GitHub, users occasionally encounter errors when pushing changes to the remote repository. A common, yet frustrating, issue is being unable to push changes due to the presence of large files that exceed GitHub's file size limitations. This issue can persist even after attempting to delete the problematic files. The following guide addresses the core reasons for this issue and offers potential solutions.

Understanding GitHub's File Size Limitations

GitHub imposes several limitations on file sizes to ensure optimal performance for both the server and users. These limitations include:

  • Individual file size limit: Files larger than 100 MB cannot be pushed.
  • Repository size limits: While there is no hard limit, repositories larger than 1 GB can pose performance issues. GitHub will start to warn users if the repository exceeds this size.

Deleting Large Files From a Commit

When you add a large file to your Git repository, even if it is later deleted from the working directory, it remains in the commit history. This inclusion in the history means Git will attempt to push this big file unless you remove its record from the commit history. Here’s how you can handle this effectively:

Using BFG Repo-Cleaner

The BFG Repo-Cleaner is specifically designed for such tasks, allowing you to remove large or sensitive files from your git history without laborious manual processes.

  1. Install the BFG Repo-Cleaner:
    You can download the latest BFG release from the BFG homepage.
  2. Remove the Large File: Suppose you need to remove a file named `largefile.zip`. Run the following command:
  • Synchronization Required: All collaborators will need to fetch the updated refs and reset any work in progress.
  • Loss of Data: Ensure you have backups before performing operations that alter repository history.
  • Broken References: All references to the old state (e.g., bookmarks, tags) might be lost.

Course illustration
Course illustration

All Rights Reserved.