Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 2

Push exceeding the 100mb limit

Solved! Go to Solution.

Hey guys,

Sorry for the "repost", i know there are been plenty of topics on this particular issue, but as a non-native english speaker, a non-programmer and a newbie github user i really struggled understanding the solutions given to this problem.

I'm working on a school project, and I unfortunately commited a 100+mb file. I then tried to push and got the error

So far I :

- Reverted the commit so that I get back the files localy

- Identified and deleted the heavy file localy

- Commited the delete

 

But the error is still the same.. Help ?

If I ever need to use Git or Git Bash or whatever, please be very clear on your instructions and do not assume I know anything about these... Because I don't ahah

 

Thanks a lot 

1 Reply
Highlighted
Solution
Community Manager
Message 2 of 2

Re: Push exceeding the 100mb limit

If you used the `git revert` command, I can see where you ran into this problem. This is because git is designed very, very well to prevent people from losing information in their repositories. In almost all cases, a git repository only grows, never shrinks. So, if I'm right about you using the `git revert` command, here's what happened:

 

  1. You commit a file larger than 100MB
  2. You attempt to push and get the error
  3. You revert the commit with `git revert` which creates a new commit where the large file doesn't exist but leaves the large file in the repository's history of commits
  4. You attempt to push and get the error again

 

There are also other ways that you could do the above that don't necessarily require the use of `git revert`. As for how to solve this problem, let me try to show you in pictures.

 

remove-bad-commit.png

 

So the first set of boxes is the state of things just after you make the commit with the large file. From there, you can execute `git reset --soft HEAD^`. This instructs git to move the `HEAD` and `master` "refs" (assuming `master` is the name of the branch you have checked out) backwards one commit. `git reset` moves the `HEAD` and current branch "ref" or pointer to a new location. The location that I gave in `git reset --soft HEAD^` is `HEAD^` (which I pronounce "head hat" because it makes it easy for me to remember). The "hat" means "one commit before". So `HEAD^` means "one commit before wherever `HEAD` is currently pointing". (If you want to do two commits before, you could specify `HEAD^^`, etc.)

 

Now, notice that the "bad commit" still exists in the second set of boxes. This is because git tries really, really, really hard to never forget anything. But, when you push, git only transmits the objects that are "reachable" by the branch you're pushing. So, even though the bad commit exists on your local machine, if you pushed at this stage, you wouldn't get the error because git wouldn't transmit the commit that contains the file that is too large.

 

So, to get to the third set of boxes, you delete the too large file and then commit everything but it. This creates the new commit on the leftward fork in the image. So when you run `git push` it shouldn't try to transmit the bad commit or the too large file.

 

I hope that helps! Let me know if you have any other questions.