How do I ignore all files in a folder with a Git repository in Sourcetree?
Add this to .gitignore:
*
!.gitignore
For Sourcetree users: If you want to ignore a specific folder, just select a file from this folder, right-click on it and do "Ignore...". You will have a pop-up menu where you can ignore "Ignore everything beneath: <YOUR UNWANTED FOLDER>"
If you have the "Ignore" option greyed out, you have to select the "Stop Tracking" option. After that the file will be added to Staged files with a minus sign on red background icon and the file's icon in Unstaged files list will change to a question sign on a violet background. Now in Unstaged files list, the "Ignore" option is enabled again. Just do as described above.
As far as I know, Git doesn't track folders, only files - so empty folders (or folders where all files are ignored) cannot be committed. If you e.g. need the folder to be present due to some step in your build process, perhaps you can have your build tool create it instead? Or you could put one empty, unignored file in the folder and commit it.
Right click on a file → Ignore → Ignore everything beneath.
If the Ignore option is grayed out then:
- Stage a file first
- Right click → Stop Tracking
- That file will appear in the pane below with a question mark → Right click on it→ Ignore