start

今天用Hexo写博客的时候在本地加入了一个大视频文件(270M)做本地测试,结果不小心使用hexo d部署到了github上,中途出现问题。

一、问题描述:

上面标注的地方已经提示的很明显了,就是我上传的一个视频文件过大(大于100M),导致部署失败。

1
2
3
4
5
6
7
8
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 1ed90a12b5f48203c8ec19d87330097b
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File statics/file.mp4 is 271.90 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/zccon/zccon.github.io.git
! [remote rejected] HEAD -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/zccon/zccon.github.io.git'
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html

按照上面错误提示第四行给出的一个地址http://git.io/iEPt8g,里面github提供了一个方法(不过我用这个方法并没有解决)。

二、定位问题

进入该地址:

主要看前两个介绍:
首先我们来看看Conditions for large files里面讲了些啥

Conditions for large files

当单个push的文件大于50M时会被发出警告(warning),但是push操作仍会继续;

当单个push的文件大于100M时就会报错了(error),这时此次push操作会被拒绝(reject),commits 也不会保存到github的repository 中。

根据前面的提示找到引起错误的文件,例如我的文件是放在主题文件夹/source/statics/xxx.mp4里,引起错误的就是xxx.mp4这个文件。

找到之后就想着怎么恢复之前的状态,来看看Removing files from a repository's history里面怎么操作的吧!

三、解决问题

3.1方法一

Removing files from a repository’s history

注:这个方法并没有解决我的问题


首先选择自己对应的系统,(比如我这里是windows系统),然后下面给出了具体的解决步骤以及指令。

1.Open Git Bash.
打开Git Bash

2.Change the current working directory to your local repository.
切换当前目录至本地仓库

3.To remove the file, enter git rm –cached:
输入git rm --cached giant_file以移除文件

1
2
$ git rm --cached giant_file
# Stage our giant file for removal, but leave it on disk

4.Commit this change using –amend -CHEAD:
输入git commit --amend -CHEAD使得change生效

1
2
3
4
$ git commit --amend -CHEAD
# Amend the previous commit with your change
# Simply making a new commit won't work, as you need
# to remove the file from the unpushed history as well

5.Push your commits to GitHub:
push至github

1
2
$ git push
# Push our rewritten, smaller commit

按照要求,我们首先找到本地仓库在哪。我这里在Hexo文件夹下有一个.deploy_git的文件夹,在这里面就是我们所有push到github的内容。可以看到我们之前的大文件在这里面也有一份。进入路径后直接按照流程指令来操作,注意自己的文件位置和名称!

结果以失败告终,后面push的时候还是提醒有大文件,说明前面的操作并没有移除文件。

3.2方法二

因为是在提交的过程中报错,需要先撤销已提交的commit,直接重置到原来的commit
目录切换至.deploy_git

  1. 查看提交记录
    1
    $ git log

2.找到提交前的commit,重置

1
$ git reset xxxxx


这里可以查到我最近提交的几次commit和时间以及对应的一串数字字母组合,找到你想恢复的那个commit的那串数字字母组合,输入指令git reset xxxxxxxxxxxxxxxxxxx,发现问题就解决了

在确定恢复哪一个commit时,我们可以到github中查看更详细的信息,包括每一个commit的push时间,编号以及更改的具体代码,这样我们就更加清楚我们需要恢复到哪一个commit中去。

这里列出了最近的commit条目

每次都更改了哪些内容:

end

相关文章
评论
分享
  • Annie主题+Gitalk评论

    本文是以Annie主题+Gitalk评论插件搭建的博客评论功能,其中涉及到Github仓库的创建和OAuth应用的申请。 一、新建github仓库首先登陆个人的github,点击New repository创建新的仓库 二、注册OA...

    Annie主题+Gitalk评论
  • Emoji表情库

    Smileys & People😀😃😄😁😆😅😂🤣😊😇🙂🙃😉😌😍😘😗😙😚😋😛😝😜🤪🤨🧐🤓😎🤩😏😒😞😔😟😕🙁☹️😣😖😫😩😢😭😤😠😡🤬🤯�...

    Emoji表情库
  • Annie主题详细使用说明

    开始之前的说明 文中所有的指令都是在Hexo文件夹下开启的命令行中执行的 代码对比 123 This is a diff block.+ This is add!- This is subtract! Bash指令 ...

    Annie主题详细使用说明
  • NavigationView头部监听事件

    参考网址 一、删除xml文件中的静态引用找到<NavigationView>控件,将控件里的静态引用删除12345678<android.support.design.widget.NavigationView a...

    NavigationView头部监听事件
  • 安卓开发之折线图

    一、新建工程Line_chart勾选自动生成activity_layout.xml文件 二、添加jar包app/src/main目录下新建libs文件夹,加入包hellocharts-library-1.5.8.jar 三、添加依赖打...

    安卓开发之折线图