file - Github,文件太大已删除。

标签 file github

我尝试将一个文件添加到我的存储库中,但超出了 github 限制。不幸的是我删除了它,但当我推送时它仍然尝试添加它。

rm dist/img/work.zip
fatal: pathspec 'dist/img/work.zip' did not match any files

如何将其从存储库中取出?

最佳答案

使用git filter-branch .

  1. 使用命令

    git filter-branch --force --index-filter \
      'git rm -r --cached --ignore-unmatch dist/img/work.zip' \
      --prune-empty --tag-name-filter cat -- --all
    
  2. 过滤器分支完成后,验证没有意外文件丢失。

  3. 现在添加 .gitignore 规则

    echo dist/img/work.zip >> .gitignore
    git add .gitignore && git commit -m "ignore rule for files"
    
  4. 现在进行推送

    git push -f origin branch
    

改编自:git rm - fatal: pathspec did not match any files

关于file - Github,文件太大已删除。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42143269/

相关文章:

git - git 对于多语言实现的最佳实践是什么?

c# - 性能方面 : File. Copy 与 C# 中的 File.WriteAllText 函数?

java - 使用两个数组搜索文件

php - 我可以用php上传整个文件夹吗?

c - 如何创建一个写入 FILE * 的库,而不是将数据写入内存? (C 编程)

git - 如果你不能提交到他们的分支,你怎么能将提交到另一个人的 github pull request 添加到你的 repo?

git - 限制某些 GitHub 用户 merge 分支

检查文件是否存在和读取权限

git - 如何重启 git/GitHub 项目?

GitHub fork 以前提交的 repo