gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
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.
As of git 1.8.2, this:
MyPrject/WebApp/Scripts/special/**/*.js
Should work according to this answer. It also works for me in Windows 7 using Sourcetree 1.6.12.0 and the version of git that it installs (1.8.4-preview20130916).
To gitignore every file and folder under a directory recursively:
MyPrject/WebApp/Scripts/special/**
Following gitignore manual page:
[...] git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname.
So, this clearly stands that there is no way to specify a certain amount of directories between two strings, like between special
and js
.
Nevertheless, you can have a .gitignore
file per directory, so maybe in your case the following content
*.js
at the following place
MyPrject/WebApp/Scripts/special/.gitignore
would be sufficient?
This works for me in on osx.
lib64/**/__pycache__/
lib/**/__pycache__/
*.py[cod]
.ipynb_checkpoints/
**/.ipynb_checkpoints/
.DS_Store
**/.DS_Store
Try executing git rm -r --cached MyPrject/WebApp/Scripts/special/
Your mentioned directory might have been cached by git and will show up on untracked files.
After clearing the cache make sure you have it mentioned on .gitignore
.
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