Even though you have removed the file in the latest commit you still have a copy of it in your history. I think you’re going to want to remove it from git completely.
You’ll probably want to rebase it out. To find out when you introduced it you could do:
git log --reverse -n1 doc/image.eps
Then copy the SHA it gives you and do an interactive rebase:
git rebase -i sha~1
Keep the ~1
in the above command, but replace the sha
with the actual SHA from the earlier command output. If the above command doesn’t work you may need to set an EDITOR
, e.g.:
EDITOR=vim git rebase -i sha~1
Replace vim
with any command line editor you’re comfortable with (emacs
, nano
, etc). You can get it to work with GUI editors like atom
but you may need to pass in additional arguments to force the process to wait until you close the window. If you use atom
you could run:
EDITOR="atom --wait" git rebase -i sha~1
This is going to take you way back in time. The very first line is going to have pick
. You’ll want to change that to an edit
. Then save, and exit your editor. Do not change any other pick
s.
This will put you back at the commit that introduced the large file. You can now remove it from git:
git rm doc/image.eps && git commit --amend
Then continue the rebase:
git rebase --continue
If this goes all the way to completion, then you’re done. You should be able to git push
. However, if it doesn’t, then you may have updated the image in a later commit. You’ll want do the same git rm doc/image.eps && git commit --amend && git rebase --continue
that we did above every time it stops.
I’m assuming quite a few things so I hope you’re comfortable enough with git, editors, and the command line to use this information.
P.S. there is likely a much shorter and more succinct way to do this, but since you’re asking this question I’m assuming you don’t want a magical git
command that will rip thru your history on its own. So first, let’s try it step by step.