How to remove a too large file in a commit when my branch is ahead of master by 5 commits

git

Solution

When you deleted your file, that will be a change and that is the unstaged change that git is complaining about. If you do a git status you should see the file listed as removed/deleted. To undo this change you should `git checkout -- <filename>`. Then the file will be back and your branch should be clean. You can also `git reset --hard` this will bring your repo back to the status where you made your commit.

I am assuming that it is the last commit that has the very large file that you want to remove. You can do a `git reset HEAD~` Then you can redo the commit (not adding the large file). Then you should be able to `git push` without a problem.

Since the file is not in the last commit then you can do the final steps without a problem. You just need to get your changes either committed or removed.

http://git-scm.com/book/en/Git-Tools-Rewriting-History

Problem

Context I'm working alone on a project and I used github until now to save my work other than on my computer. Unfortunately, I added a very large file to the local repository : 300mb (which exceed Github's limit). What I did I will try to make an history of what I made : I (dumbly) added everything to the index : ``` git add * ``` I committed changes : ``` git commit -m "Blablabla" ``` I tried to push to origin master ``` git push origin master ``` It took a while, so I just CTRL+C, and repeated step 2 and 3 four times, until I realised that a file was too large to be pushed to github. I made the terrible mistake to delete my large file (I don't remember if I did a git rm or a simple rm) I followed the instructions on (https://help.github.com/articles/remove-sensitive-data) When I try to git filter branch, I get the following error : "Cannot rewrite branches: You have unstaged changes."

Original source

Related problems