Git - how to ignore files inside a folder

Asked

Viewed 866 times

5

How do I view the folder without Versing all the files that are inside it?

I have tried several ways and I can’t, either versioning the files or stopping the folder. I need it created for the proper functioning of the project.

The folder is at the root of the project.

I don’t want to view cache files

my attempts:

views-cache/*
views-cache/
views-cache/**/* 

2 answers

3


Create a file .gitignore inside the briefcase views-cache and put as content of it:

*
!.gitignore

this will cause all files in the folder to be ignored except the .gitignore
then use the command git add views-cache/.gitignore

2

create a text file and save with the name .gitignore inside the briefcase in each row of the file put the file name or regex of the files you want to ignore:

views-cache/* 

documentation: https://git-scm.com/docs/gitignore

if you have already committed the folder and/or files run the command below

git rm --cached -r /views-cache

the -ris recursive, ie removes the files inside the folder as well

  • i already have the . gitignore and already tried this way you spoke and it stops to Versionar the folder, I want to stop only the files inside the folder

  • you’ve committed some of those files?

  • I just tested with this line: views-cache/* . I deleted the folder. git, I gave git init again, an add and commit and the files inside the views-cache were commited, that is, they were not ignored as I need

  • How’s your directory tree?

  • root->views-cache

  • files that are generated: views-cache/Registers-Brands-update.793678081f3c5a6081d5061f3df4e175.rtpl.php

  • updated the answer, see there

  • failed, the views-cache folder is gone

Show 3 more comments

Browser other questions tagged

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