git tries to upload deleted file that is not staged
Asked Answered
F

1

7

I had a file F that exceeded 100 MB limit that I tried to push. So the push failed. I then removed the file, because it could not be pushed and assumed I needed to do add . ; commit and push again. In the auto generated commit it said deleted file F. Upon push it still tried to upload that file. Well ok, so I figured I need to unstage F. SO I did reset F. I got the message fatal: ambiguous argument 'out': unknown revision or path not in the working tree. No idea what that meant, so I tried to make git show me the staged files diff --cached, but the output is empty. I am confused about the situation and how I can untangle it.

To recap the chain :

$> git add. ; git commit

$> git push

$> remote: error: File F is 143.41 MB; this exceeds GitHub's file size limit of 100.00 MB

$> rm F

$> git add. ; git commit

$> git push

$> remote: error: File F is 143.41 MB; this exceeds GitHub's file size limit of 100.00 MB

$> git diff --cached

$>

Foolscap answered 15/10, 2016 at 19:27 Comment(1)
You have your large file in some older commit. You need to re-write history to get rid of it. You can always inspect your local history using graphical interface provided by gitk. git log --name-only is your friend as well. Use git commit --amend` or git reabse -i to re-write history.Wideman
B
11

The problem is that the file is already part of the historical commit.

You need to get back to the commit and amend it:

# reset to previous commit but keeping content:
git reset --soft "HEAD^"
# potentially modify the tree content
# amend the old commit with the file removed:
git commit --amend
# push:
git push
Bicentennial answered 15/10, 2016 at 19:36 Comment(2)
Thanks, that did it. What exactly did the first command do though? What is "HEAD^"?Foolscap
@lotolmencre : that identifies the commit previous to the HEAD.Bicentennial

© 2022 - 2024 — McMap. All rights reserved.