这些文件仍然存在于你的git历史记录中。从问题描述中看,git历史记录示例为:
$ git log --oneline
aaaaaaa Update .gitignore and remove big files
bbbbbbb accidentally add big files to repo
ccccccc update foo
ddddddd update bar
由于推送提交 bbbbbbb
的内容,推送失败,但是如果文件不在当前已检出的版本中,也就是在项目历史记录中,这并不重要。
可以通过检查特定文件/路径的历史记录来确认上述情况:
$ git log --all --format=%H -- big.file
aaaaaaa Update .gitignore and remove big files
bbbbbbb accidentally add big files to repo
如果big.file
太大,无法推送到github,则需要将提交列表清空。
从历史记录中彻底删除文件
有许多方法可以防止尝试将big.file
推送到远程仓库,但基于问题中的信息,最简单的方法是:
$ git reset --hard ccccccc
这将删除提交记录 aaaaaaa
和 bbbbbbb
,因此不会尝试将 big.file
推送到远程仓库。
.gitignore 的目的
.gitignore
文件影响将文件添加到代码库中,它们不会影响已经在索引中的文件。这就是为什么将文件添加到 .gitignore
中对 '问题' 没有产生影响的原因。
git status
命令的输出。:) - atupal