lo tolmencre lo tolmencre - 1 month ago 6
Git Question

git tries to upload deleted file that is not staged

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


$>

Answer

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