I have one directory tree with many kind of different files. There are 300 directories on the parent directory. Each directory could have other sub directories.
I only want to track *.cocci on all sub directories. Here is my .gitignore:
* !*.cocci
But it do not work, as the files on sub directories are not tracked. How can I tell git that I only want to track *.cocci on all sub directories?
Removing Files To remove a file from Git, you have to remove it from your tracked files (more accurately, remove it from your staging area) and then commit. The git rm command does that, and also removes the file from your working directory so you don't see it as an untracked file the next time around.
Enter git add --all at the command line prompt in your local project directory to add the files or changes to the repository. Enter git status to see the changes to be committed.
If you want to maintain a folder and not the files inside it, just put a ". gitignore" file in the folder with "*" as the content. This file will make Git ignore all content from the repository.
Read this question.
You want:
# Blacklist everything * # Whitelist all directories !*/ # Whitelist the file you're interested in. !*.cocci
Note, this'll track only *.cocci
files. Yours doesn't work because you ignore everything (that's the first line), which ignores all subdirectories.
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