There is a big .exe file in a subfolder in my project, my fold tree is like:
.
├── folder1
│ └── theBigFileThatIWantToIgnore.exe
├── folder2
│ ├── fileA
│ └── fileB
│———.gitignore
└── ...
And at first, I didn't mention that this "theBigFileThatIWantToIgnore.exe" is larger than 100MB so git bash noticed me it.
then, I tried to ignore this .exe file by using .gitignore, my .gitignore file is:
/folder1/theBigFileThatIWantToIgnore.exe
and before I git push
again, I used git rm -r --cached .
, but it is useless...
HELP MEEEEE!thanks!
CodePudding user response:
This should ignore it:
cd /path/to/repo
echo "/folder1/theBigFileThatIWantToIgnore.exe">>.gitignore
git rm --cached folder1/theBigFileThatIWantToIgnore.exe
git check-ignore -v -- folder1/theBigFileThatIWantToIgnore.exe
# you should see a .gitignore rule
However, that will allow you to create a new commit without that exe.
That will not, however, remove the exe from the past comimts/history of the repository, which will remain huge as a result.
To truly cleanup the repository, install git filter-repo
, and use a path-based filtering
git filter-repo --path folder1/theBigFileThatIWantToIgnore.exe --invert-paths
You will need to force push the result though, so make sure any collaborator on that repository is aware of that change (history rewrite).