0

I have a large folder which is GB in size. The files inside it exceeds 100 MB. I did staged the folder, then commit. Then I executed:

git push origin master

But I got errors. From the errors I knew that particular folder can not be uploaded. I moved it outside my working directory.

Now I commit the directory again and again executed

push origin master

Git still complains about the large files although I have deleted them.

I checked the status using:

git status

I get this message:

On branch master
Your branch is ahead of 'origin/master' by 5 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

If I try tp push the changes to the origin master, I get the error about the large files. I am unable to remove them or untrack them.

My directory looks like this:

C:\Users\myuser\Documents\GitHub\myproject\data\largedirecor

The large directory is the problematic which I moved it outside my project directory. But this did not solve the issue.

How to push the changes without being chocked because of the large file? how to make git forget it.

user9371654
  • 2,160
  • 16
  • 45
  • 78
  • Possible duplicate of [How to remove/delete a large file from commit history in Git repository?](https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – phd Jul 20 '18 at 13:41

1 Answers1

1

You have already checked in the files, thus git is aware of them. Simply deleting the files will not have the desired effect, you need to get rid of the commit or alter the commit where you added them.

You can use

git rebase -i origin/master

to interactively change the commits you did. An editor will open.

You now have 2 options:

1) All the files were introduced in one commit with no other files. In this case, simply remove the line of the offending commit. It will be removed from your history and consequently not be pushed.

2) There are other files in the same commit: Replace pick at the beginning of the line with edit. Then edit the commit by removing the offending files and execute git rebase --continue.

Afterwards, the files are no longer in your commit history.

Markus
  • 684
  • 5
  • 11