.gitignore with wildcards for filenames
.gitignore
won't ignore a file that's already in your repository. You have to first remove the file for your repository.
You can remove a file from the repository without deleting the actual file with git rm --cached
.
git rm --cached WinAppSetup/setup.exe
In this sort of situation I usually have the new .gitignore
entry and the removal of the ignored file from the repository in the same commit.
Mr Moose
Updated on June 04, 2022Comments
-
Mr Moose almost 2 years
My .gitignore file has the following entries. I am trying multiple things here as I can't seem to get my file ignored;
WinAppSetup/*.exe /WinAppSetup/*.exe WinAppSetup/setup.exe **/WinAppSetup/setup.exe
When I run
git status
from git bash, I still see;modified: WinAppSetup/setup.exe
What entry in my .gitignore will allow me to ignore this file?
After editing .gitignore, do I need to close and re-open git bash to have the .gitignore file re-read?
UPDATE
As per user2407038's comment, the issue was that the file already existed in the repository. I was able to remove the file locally, stage and then commit those changes and update my remote. A new build of the application then successfully ignored the file.
It seems I can also update my .gitignore file without having to close and re-open git bash too.
-
Mr Moose over 6 yearsI'm accepting this answer, as it seems to do what I need, but the suggestion provided by @user2407038 is what really helped me fix this specific issue.