How to ignore Folders/Directories in GIT? Ex: . Metadata , . recommenders

Asked

Viewed 14,542 times

3

I have a project in . git in which I believe it is necessary to ignore some files. However, I put the command and the folder keeps appearing in git status. I did it the following way:

creating gitignore file

touch .gitignore

Including files/directories in . gitignore to be ignored

# ignora os arquivos com extensões 
.gitignore
# ignora quaisquer diretórios chamados "metadata"
.metadata/
.recommenders/

Only when you give git status the changes that should not appear continue to appear, because . gitignore is gone from git status but the folder keeps appearing.

Pasta ainda aparecendo no git status

2 answers

8

Only using gitignore. Note that if you have already added the files in the repository, you need to remove them.

git rm --cached -r /.metadata

Use the argument -r (recursive) when removing a folder and all the files inside it.

5

gitignore serves exactly that, create it at the root of your project with the name .gitignore and inside it insert the code.

# lembre de colocar o nome da pasta sem o ponto na frente
# Para ignorar todos arquivos e sub-pastas localizados na pasta metadata/plugins/
metadata/plugins/nome-do-plugin

# Para ignorar todos os arquivos e sub-pastas da pasta metadata/
metadata/

If you still have doubts see this post that explains well how to solve this problem.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.