Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.gitignore does not work for subfolder of ignored folder

I'm using Laravel and the Github program for subversions. In my .gitignore file i type:

/vendor

My project structure looks like this:

Root
 app
 bootstrap
 public
 vendor

And it's all the files in vendor i want to ignore in git. Most of the files works to ignore there with typing /vendor in my .gitignore, but some files don't.

The files that doesn't work are autoload.php - vendor/autoload.php

And files in vendor/composer - like:

autoload_classmap.php
autoload_namespaces.php
autoload_real.php
ClassLoader.php
installed.json

What am i doing wrong in my .gitignore file?

like image 305
Lemaru Avatar asked Mar 20 '15 12:03

Lemaru


People also ask

Does Gitignore work in subfolder?

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 Gitignore ignore folders?

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 .

Why is Gitignore not ignoring my files?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them.


1 Answers

After adding vendor folder in gitignore did you clear the git cache

git rm -r --cached vendor

git add .
git commit -m ".gitignore"

This will remove vendor folder completely.

like image 102
SMNTB Avatar answered Oct 21 '22 01:10

SMNTB