2017-02-09 60 views
2

我有一个文件,我试图添加到我的回购,但超过了github限制。不幸的是我删除了它,但是当我做推时它仍然尝试添加它。Github,文件太大已被删除。

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

我该如何获得它的回购?

回答

2

使用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