MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

Git error: GH001: Large files detected. You may want to try Git Large File

Errors

C:\RajeshAll\github\ppt>git push origin master
Enumerating objects: 750, done.
Counting objects: 100% (694/694), done.
Delta compression using up to 8 threads
Compressing objects: 100% (584/584), done.
Writing objects: 100% (634/634), 606.82 MiB | 2.37 MiB/s, done.
Total 634 (delta 157), reused 15 (delta 1), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (157/157), completed with 42 local objects.
remote: error: Trace: f7d8654f7202cd414ba887663661bdefcad7e457d2abeecfdeb2a7777bdc31a1
remote: error: See https://gh.io/lfs for more information.
remote: error: File azure/slides/azure-getting-started/Session-1.pdf is 425.95 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 github.com:rajeshkumarin/ppts.git
 ! [remote rejected]     master -> master (pre-receive hook declined)
error: failed to push some refs to 'github.com:rajeshkumarin/ppts.git'

Solution

To remove Session-1.pdf from your commit in Git, follow these steps:

Revert the Commit: If the commit containing Session-1.pdf has not been pushed to the remote repository, you can use the following command to undo this commit while keeping the changes in your working directory:

$ git reset --soft HEAD~1

This command will move the current HEAD back to the previous commit, but keep the changes in your staging area.

Remove the File: Once the commit is undone, you need to remove the file from the staging area:

$ git reset HEAD azure/slides/azure-getting-started/Session-1.pdf

This command unstages Session-1.pdf but leaves it in your working directory.
Commit Again: Now, commit your changes again, excluding Session-1.pdf:


$ git commit -m "Your commit message"

Deal with the File Separately: If you still need to track Session-1.pdf but it is too large for GitHub, consider using Git Large File Storage (LFS). Install Git LFS and then set up LFS for your file types:


$ git lfs install
$ git lfs track "*.pdf"
$ git add .gitattributes

After setting up Git LFS, add your large file:


$ git add azure/slides/azure-getting-started/Session-1.pdf
git commit -m "Add large file with LFS"
Push Your Changes: Finally, push your changes to the remote repository:


$ git push origin master

Other Methods

there are alternative ways to remove a large file from your Git history, including using git filter-branch and using interactive rebase. These methods are generally less efficient or more manual but may work if you’re unable to use git-filter-repo or BFG.

Method 1: Using git filter-branch (Older, but Effective)
git filter-branch can rewrite Git history by removing the file from all commits, but it’s slower and more prone to errors in larger repositories. Here’s how to use it:

Run git filter-branch to Remove the File

$ git filter-branch --force --index-filter "git rm --cached --ignore-unmatch events.zip" --prune-empty --tag-name-filter cat -- --all

Replace events.zip with the name of your large file.

Clean Up and Force Push

Run the following to clean up your repository:

$ rm -rf .git/refs/original/
$ git reflog expire --expire=now --all
$ git gc --prune=now --aggressive

Finally, force push the changes to GitHub:

$ git push origin --force --all

Note: This method modifies the entire history of the repository, so collaborators will need to re-clone or reset their repositories after this.

Error

[devopsallsites@47 bestdevops.com-]$ git filter-branch --force --index-filter "git rm --cached --ignore-unmatch error_log" --prune-empty --tag-name-filter cat -- --all
WARNING: git-filter-branch has a glut of gotchas generating mangled history
         rewrites.  Hit Ctrl-C before proceeding to abort, then use an
         alternative filtering tool such as 'git filter-repo'
         (https://github.com/newren/git-filter-repo/) instead.  See the
         filter-branch manual page for more details; to squelch this warning,
         set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...

Cannot rewrite branches: You have unstaged changes.

You’re trying to remove a large file (error_log, ~347 MB) from your Git history because GitHub rejects files >100MB, and you’re getting this error when running git filter-branch:

Cannot rewrite branches: You have unstaged changes.


✅ Step-by-Step Fix

🔧 Step 1: Stash or clean your changes

You need to make sure your working directory is clean before rewriting history.

Run:

git stash push --include-untracked

Or, if you don’t need any local changes:

git reset --hard
git clean -fd


🔧 Step 2: Run git filter-branch to remove the large file

git filter-branch --force --index-filter \
"git rm --cached --ignore-unmatch error_log" \
--prune-empty --tag-name-filter cat -- --all

This will:

  • Remove error_log from all commits
  • Rewrite your full Git history

🔧 Step 3: Force push the cleaned repo

After history rewrite, force push to overwrite the remote:

git push origin --force --all
git push origin --force --tags


0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x