2

I had a file that I tried to add to my repo but is over the github limit. Unfortunately I deleted it but when I do a push it still tried add it.

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

How do I get it out the repo?

LeBlaireau
  • 17,133
  • 33
  • 112
  • 192

1 Answers1

2

Use git filter-branch.

  1. Use the command

    git filter-branch --force --index-filter \
      'git rm -r --cached --ignore-unmatch dist/img/work.zip' \
      --prune-empty --tag-name-filter cat -- --all
    
  2. After the filter branch is complete, verify that no unintended file was lost.

  3. Now add a .gitignore rule

    echo dist/img/work.zip >> .gitignore
    git add .gitignore && git commit -m "ignore rule for files"
    
  4. Now do a push

    git push -f origin branch
    

Adapted from: git rm - fatal: pathspec did not match any files

Community
  • 1
  • 1
Gautam Krishna R
  • 2,388
  • 19
  • 26