[英]Proper .gitignore file for a Neos Flow project?
我最近使用composer create-project --keep-vcs neos/flow-base-distribution ProjectName
創建了一個新項目,我對它生成的 .gitignore 文件有點困惑:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
它基本上從 VCS 中丟棄了幾乎所有文件,包括整個 Packages/Application 文件夾,我認為我的大部分代碼都會放在那里。 那么什么給呢? 為什么 .gitignore 文件如此廣泛?
我以前沒有使用 neos-flow 的經驗,但我在 Composer 的幫助下將它安裝在兩台不同的 Ubuntu 計算機上。 我的 .gitignore 文件輸出兩次都與您的輸出相同。
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
我的項目的原始結構是
. .. .editorconfig .git .github .gitignore Build Configuration Data Packages Readme.rst Web bin composer.json composer.lock flow flow.bat
當我刪除 .gitignore 中聲明的所有文件夾和文件時,我的項目結構是這樣的
. .. .editorconfig .git .github .gitignore composer.json composer.lock
如您所知,.gitignore 文件的目的是允許您忽略您永遠不想提交到存儲庫中的文件,例如編輯器備份文件、構建產品或本地配置覆蓋。
我認為 Neos-flow 只需要應用 .gitignore 后剩余的那些文件。 那些是composer.json 和 composer.lock
composer.json的目的是顯示有關項目的詳細信息,如名稱、描述、許可證信息。
composer.lock顯示所有包和項目的依賴項、它們的名稱、詳細信息和下載包的 url。
{
"name": "neos/flow-base-distribution",
"description": "Flow Base Distribution",
"license": "MIT",
"support": {
"email": "hello@neos.io",
"slack": "http://slack.neos.io/",
"forum": "https://discuss.neos.io/",
"wiki": "https://discuss.neos.io/c/the-neos-project/project-documentation",
"issues": "https://github.com/neos/flow-development-collection/issues",
"docs": "https://flowframework.readthedocs.io/",
"source": "https://github.com/neos/flow-base-distribution"
},
"config": {
"vendor-dir": "Packages/Libraries",
"bin-dir": "bin"
},
"require": {
"neos/flow": "~6.0.0",
"neos/welcome": "~6.0.0"
},
"require-dev": {
"neos/kickstarter": "~6.0.0",
"neos/buildessentials": "~6.0.0",
"neos/behat": "dev-master",
"phpunit/phpunit": "~8.1",
"mikey179/vfsstream": "~1.6"
},
"repositories": {
"distributionPackages": {
"type": "path",
"url": "./DistributionPackages/*"
}
},
"replace": {
"typo3/flow-base-distribution": "self.version"
},
"suggest": {
"ext-pdo_sqlite": "For running functional tests out-of-the-box this is required"
},
"scripts": {
"post-update-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
"post-install-cmd": "Neos\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
"post-package-update": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall",
"post-package-install": "Neos\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall"
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "06d49a77babbafa5a03d726865e61dc3",
"packages": [
{
"name": "composer/ca-bundle",
"version": "1.2.4",
"source": {
"type": "git",
"url": "https://github.com/composer/ca-bundle.git",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/ca-bundle/zipball/10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"reference": "10bb96592168a0f8e8f6dcde3532d9fa50b0b527",
"shasum": ""
},
"require": {
"ext-openssl": "*",
"ext-pcre": "*",
"php": "^5.3.2 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7 || 6.5 - 8",
"psr/log": "^1.0",
"symfony/process": "^2.5 || ^3.0 || ^4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\CaBundle\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.",
"keywords": [
"cabundle",
"cacert",
"certificate",
"ssl",
"tls"
],
"time": "2019-08-30T08:44:50+00:00"
}]}
composer.lock json 中的 _readme 鍵顯示了 composer.lock 的用途
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
因此,簡而言之,您的 .gitignore 絕對正確且准確。 我也在我的兩台 ubuntu 電腦上安裝了它,兩者都是一樣的。
.gitignore
在其存儲庫下有兩種模型:
/Build/
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
https://github.com/neos/flow-development-distribution/blob/master/.gitignore
/Build/Behat/*
/Build/BuildEssentials
/Build/Reports
/Build/Resources
/Configuration/
/Data/
/Packages/
/Web/
/bin/
/Readme.txt
/Upgrading.txt
/Readme.rst
/Upgrading.rst
/flow
/flow.bat
因為我是一個狂熱的 Flow 用戶,所以我可以解釋為什么Packages/
目錄被排除在外:
正如你在composer.json
看到的,有這個部分:
"repositories": {
"distributionPackages": {
"type": "path",
"url": "./DistributionPackages/*"
}
},
這告訴作曲家在DistributionPackages/
目錄中查找您自己的包。 這比在Packages/
目錄中混合自己的包和依賴項要干凈得多,而且還有助於依賴項管理本身(因為只有包目錄中的composer.json
需要包含包依賴項 - 即不需要在根composer.json
)。 有關更多信息,請參閱https://docs.neos.io/cms/manual/dependency-management#the-path-repository-setup和https://www.neos.io/blog/project-repository-best-practice.html相關信息(這不僅適用於 Neos 站點包,還適用於每個項目特定的包)。
至於其他排除的文件:由於這些文件是由composer install
創建的,因此不需要由 git 跟蹤。
例外:您通常希望包含Web/
目錄(但排除非特定內容,如Web/_Resources/
或Web/index.php
),即網站根目錄中所需的網站圖標或其他靜態文件。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.