今天在整理自己的文档时,就想着传到git上,以后编辑的时候来回方便,就不需要考虑文档不一致的问题了,然后把自己写的文档都传到git上,发现上传的时候有一个压缩文件一直上传不了,原来是github有限制,针对100M以上的单个文件不允许上传需要修改上传大小设置,因为文件也不是很重要,就想着删除后在继续上传,但是还是抱错,这里记录一下解决方法:
报错信息
利用git push进行上传文件,出现异常,抱错信息如下:
[wolf@wulaoer.org 🔥🔥🔥🔥 wulaoer ]$ git push Enumerating objects: 141, done. Counting objects: 100% (141/141), done. Delta compression using up to 16 threads Compressing objects: 100% (137/137), done. Writing objects: 100% (140/140), 350.34 MiB | 1.70 MiB/s, done. Total 140 (delta 31), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (31/31), completed with 1 local object. remote: error: Trace: b1289923c53481feb455506653fa776d4aed03a3cc7e877eeb044ffe693b89c0 remote: error: See http://git.io/iEPt8g for more information. remote: error: File python/CV.rar is 350.15 MB; this exceeds GitHub's file size limit of 100.00 MB remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com. To github.com:wolf27w/wulaoer.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'github.com:wolf27w/wulaoer.git'
大致意思是上传的文档是350MB,超过了最大100MB的限制,因为我这里不想要了就把CV文件删除掉,然后重新push,还是报上面的错误。下面看看如何解决的。
解决方法
首先需要把上次提交记录找出来,这里使用了rev-list找出所有的记录,并使用grep筛选出关键词。
[wolf@wulaoer.org 🔥🔥🔥🔥 wulaoer ]$ git rev-list --objects --all | gre p "CV" dccd504e9102a569051d1e3a9b9b0583535fbdd0 python/CV.rar
然后把提交记录删除掉,然后重新提交即可。
[wolf@wulaoer.org 🔥🔥🔥🔥 wulaoer ]$ git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch python/CV.rar' --prune-empty --tag-name-filter cat -- --all WARNING: git-filter-branch has a glut of gotchas generating mangled history rewrites. Hit Ctrl-C before proceeding to abort, then use an alternative filtering tool such as 'git filter-repo' (https://github.com/newren/git-filter-repo/) instead. See the filter-branch manual page for more details; to squelch this warning, set FILTER_BRANCH_SQUELCH_WARNING=1. Proceeding with filter-branch... Rewrite e2c2425be61d68ccf325cdcbeb1fcfa5b7d44da6 (1/8) (0 seconds passedRewrite 3352428a4a12f26290e73361841b60853b2c3e5b (2/8) (0 seconds passedRewrite 4096652927116fd21df704f9d46f961a2740e3b6 (3/8) (0 seconds passedRewrite 8e9e4010b8f91924b991e7da95d1423f80421b9c (4/8) (0 seconds passedRewrite 5d1839221b31a9df36ae53fd6ee0ec0dbb07f073 (5/8) (0 seconds passedRewrite b0e9d77c4f80050a8b516fcfc535d5f311ce03dc (6/8) (0 seconds passed, remaining 0 predicted) rm 'python/CV.rar' Rewrite db61538963be768087835809955028c0fbd0434f (7/8) (0 seconds passedRewrite 3b2a6db0f90fd3a5958283d8251d5ad0f87b45f5 (8/8) (0 seconds passed, remaining 0 predicted) Ref 'refs/heads/master' was rewritten WARNING: Ref 'refs/remotes/origin/master' is unchanged Ref 'refs/stash' was rewritten [wolf@wulaoer.org 🔥🔥🔥🔥 wulaoer ]$ git push origin --force --all Enumerating objects: 140, done. Counting objects: 100% (140/140), done. Delta compression using up to 16 threads Compressing objects: 100% (136/136), done. Writing objects: 100% (139/139), 180.06 KiB | 548.00 KiB/s, done. Total 139 (delta 31), reused 0 (delta 0), pack-reused 0 remote: Resolving deltas: 100% (31/31), completed with 1 local object. To github.com:wolf27w/wulaoer.git 5d18392..a253a51 master -> master
这里用到几个命令汇总一下。
# 删除original文件夹 rm -rf .git/refs/original/ # 修剪旧的reflog条目 git reflog expire --expire=now --all # 验证数据库中对象的连接性和有效性 git fsck --full --unreachable # 打包解压缩的对象。 删除冗余的对象 git repack -A -d # 清理不必要的文件并优化本地存储库 git gc --aggressive --prune=now # 强制推送到远程git仓库 $ git push origin --force --all
也有说利用git log找到记录,然后使用git rebase删除记录,然后刷新重新提及即可,但是我这里试了一下,第一个文件的时候可以,但是我删除第二个大文件的时候就不行了,所以这里就不记录了,没有了,看看其他的吧。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏