chandan-choudhury
chandan-choudhury

Reputation: 9

Why 'git push origin master' is pushing old files to GitHub?

I am creating a GitHub pages, I already deploy the react app to GitHub pages with custom domain.

Earlier there is a file over 100MB, but when I came to know that GitHub allows only 100MB, I replaced that file with a 29MB file.

When I am pushing the new changes to GitHub master branch using "git push origin master" I am getting an error see the attached image

Click to see the Error Image

Upvotes: 0

Views: 1204

Answers (2)

VonC
VonC

Reputation: 1327224

If you simply replaced a file that was already committed, Git will try to push the full history for that file, and that will include the old one (100MB).

Instead of filter-branch, try instead:

Install it first. (python3 -m pip install --user git-filter-repo)

Then, for example:

git filter-repo --strip-blobs-bigger-than 10M

You will the need a git push --force.

Note: do not "reset to a commit where your (large) file is not present": a commit represents a snapshot of the full repository (all files)

By resetting to an old commit where your file is "not present", you would loose also all other new or modified files.
You need to filter your existing repository history in order to remove just that one file.

Upvotes: 1

AKX
AKX

Reputation: 169298

The old large file is likely still part of your local Git history and as you know, the whole history of the branch is pushed.

You'll need to make sure it isn't in an earlier commit either, eg by reset ing back to a commit where the video isn't there, then committing only the new smaller one.

Upvotes: 2

Related Questions