Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ignore all _notes directories with GIT

I need your help: I'm currently working on a web project with another person. I'm using NetBeans to develop the code, while he's using Dreamweaver. We would like to ignore all Dreamweaver _notes directories (these directories contain files produced by Dreamweaver itself). We don't know the exact path of these directories. We can find them at /a/b/c/_notes/f or maybe at /_notes/a/b/c or in tens other places. We tried to add

/_notes/
/nbproject
configs/

and

/_notes
/nbproject
configs/

and also

*_notes*
/nbproject
configs/

to the .gitignore file, but the _notes directories are still tracked. Any suggestions? Thank you in advance!

like image 441
matteopuc Avatar asked Feb 26 '14 10:02

matteopuc


People also ask

How do I ignore a directory in Git?

A . gitignore file is a plain text file that contains a list of all the specified files and folders from the project that Git should ignore and not track. Inside . gitignore , you can tell Git to ignore only a single file or a single folder by mentioning the name or pattern of that specific file or folder.

Does Gitignore apply to subdirectories?

gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.

Can I have multiple Gitignore?

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 . gitignore files.


1 Answers

The correct answer is

_notes/

That is, ignore all things named _notes that are directories (hence the trailing slash).

edit: I have just seen that you say that directories are still tracked. You cannot ignore something that is already tracked, so what you must do is remove those directories from the index first, and then add the correct line to .gitignore.

To delete the files from git, but not from the filesystem, use:

git rm -r --cached path/to/_notes

If you wish to remove those files from the filesystem too, just drop the --cached option.

like image 87
Carlos Campderrós Avatar answered Oct 04 '22 03:10

Carlos Campderrós