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.
. gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.
The process of cloning ignores the . gitignore file. If a file is added, committed and another commit with the . gitignore is created, the file will still be part of the repository and therefore cloned.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
A trailing " /** " matches everything inside. For example, " abc/** " matches all files inside directory " abc ", relative to the location of the . gitignore file, with infinite depth. A slash followed by two consecutive asterisks then a slash matches zero or more directories.
.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With