Git试图上传未暂存的已删除文件

4
我曾经有一个文件F超过了100MB的限制,我试图进行推送,但是推送失败了。之后,我删除了这个文件,因为它无法被推送,我认为我需要执行add . ; commitpush来重试。在自动生成的提交中,它说删除文件F。然而,在push时,它仍然尝试上传该文件。好吧,所以我想我需要取消暂存 F。于是我执行了 reset F。我收到了消息fatal: ambiguous argument 'out': unknown revision or path not in the working tree.我不知道这是什么意思,所以我尝试让git显示已暂存的文件diff --cached,但输出为空。我对这种情况感到困惑,不知道如何解决。
回顾一下整个事件链: $> git add. ; git commit $> git push $> remote: error: 文件F大小为143.41 MB;这超过了GitHub的文件大小限制100.00 MB $> rm F $> git add. ; git commit $> git push $> remote: error: 文件F大小为143.41 MB;这超过了GitHub的文件大小限制100.00 MB $> git diff --cached $>

你的大文件在某个旧版本中。你需要重写历史记录以摆脱它。你可以使用gitk提供的图形界面检查本地历史记录。git log --name-only也是你的好帮手。使用git commit --amendgit rebase -i来重写历史记录。 - Matt Kucia
1个回答

9
问题在于该文件已经包含在历史提交中。您需要回到该提交并进行修改:
# 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

谢谢,它奏效了。不过第一个命令具体做了什么?"HEAD^"是什么? - lo tolmencre
@lotolmencre:这个命令可以识别HEAD之前的提交。 - Zbynek Vyskovsky - kvr000

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接