1

I've suddenly added some large files to GIT VCS repository.

I and committed them. And I don't know how to remove them.

I tried searching and tried some ways but I couldn't find a way to find them and remove them.

I am using GIT CLI.

thank you for your help.

Edit: I'm using android studio with grade. some *.pid files added to project that committed in project.

  • 3
    Possible duplicate of [How to remove/delete a large file from commit history in Git repository?](https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – Mad Physicist Aug 29 '17 at 03:17

1 Answers1

0

I had this problem before try these commands: first find large files with this command: git rev-list --objects --all | git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' | awk '/^blob/ {print substr($0,6)}' | sort --numeric-sort --key=2 and them try to remove them with this command. git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch path/to/large/file' --prune-empty --tag-name-filter cat -- --all

this command will remove a alrge file from all your repository means all commits and tags and branches.

sajad abbasi
  • 1,988
  • 2
  • 22
  • 43
  • 1
    Yeah it worked. there are some large files like *.pid what are they and how created? I am using android studio. –  Aug 29 '17 at 03:17
  • 1
    I think those are created by Java and Gradle it might be closed suddenly that could cause to dump memory and create those files. try to add `*.pid` in your `.gitignore` file to avoid add them again to the repository. – sajad abbasi Aug 29 '17 at 03:20