Home > front end >  Exclude a specific file Loader.php from Zend folder under vendor folder
Exclude a specific file Loader.php from Zend folder under vendor folder

Time:09-20

Below is the entry I added in .gitignore to exclude Load.php file so that any change to this file is tracked. I don't seem to find the mistake in my rules. Please help me figure it out.

Path to the file: public_html/vendor/magento/zendframework1/library/Zend

/public_html/vendor
!/public_html/vendor/magento

/public_html/vendor/magento/*
!/public_html/vendor/magento/zendframework1

/public_html/vendor/magento/zendframework1/*
!/public_html/vendor/magento/zendframework1/library

/public_html/vendor/magento/zendframework1/library/*
!/public_html/vendor/magento/zendframework1/library/Zend

/public_html/vendor/magento/zendframework1/library/Zend/*
!public_html/vendor/magento/zendframework1/library/Zend/Loader.php

CodePudding user response:

Add at least !/public_html/vendor/*/:

/public_html/vendor/*
!/public_html/vendor/*/
!public_html/vendor/magento/zendframework1/library/Zend/Loader.php

(no trailing slash after Loader.php, since it is a file, not a folder)

If you do not whitelist folders (here, subfolders of vendor/), you won't be able to exclude files, since the parent folders are ignored.

The general rule is:

It is not possible to re-include a file if a parent directory of that file is excluded.

Double-check with git check-ignore -v -- path/to/file

Also, make sure the file was not already tracked:

cd /path/to/repository
git rm --cached  -- public_html/vendor/magento/zendframework1/library/Zend/Loader.php
  • Related