This page has moved to Adobe Experience League and will be redirected soon.
Composer install command overides .gitignore file, Adobe Commerce
Composer install command overides .gitignore file, Adobe Commerce
This article provides a solution for when a tracked .gitignore
file is overriden by composer on Adobe Commerce on cloud infrastructure 2.4.2-p1 and 2.3.7.
Affected products and versions
Adobe Commerce on cloud infrastructure 2.4.2-p1 and 2.3.7.
Issue
.gitignore
file is being overwritten when running composer install command.
Steps to reproduce :
Create an empty directory for your workspace.
Run this command in the root directory:
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition:2.4.2-p1.
# or 2.3.7
Then run the following commands:
echo "/this/line/should/stay" >> .gitignore
git init
git add * && git add .*
git commit -m "Init"
# file commited to repo
rm -rf vendor/*
composer install
git diff
diff --git a/.gitignore b/.gitignore
index c144521..7092a56 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,4 +70,3 @@ atlassian*
/generated/*
!/generated/.htaccess
.DS_Store
-/this/line/should/stay
Expected result :
.gitignore
is not overriden by composer.
Actual result :
.gitignore
is overriden by every composer install run.
Solution
To keep your custom .gitignore file
you need to ignore it in the magento-deploy-ignore
section.
{
...
"extra": {
"magento-deploy-ignore": {
"*": [
"/.gitignore"
]
}
...
}
Was this article helpful?
Yes
No
1 out of 1 found this helpful