最佳实践 Laravel gitignore

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32688672/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 12:22:32  来源:igfitidea点击:

Best Practice Laravel gitignore

gitlaravel

提问by ssuhat

I want to ask about best practice for Laravel.

我想问一下 Laravel 的最佳实践。

I use gulp for my js and css. Which one should i include on push at the asset folder (use "gulp" on server) or public folder (gulp result)?

我为我的 js 和 css 使用了 gulp。我应该在资产文件夹(在服务器上使用“gulp”)或公共文件夹(gulp 结果)推送时包含哪一个?

采纳答案by VonC

Which one should i include on push at the asset folder (use "gulp" on server) or public folder (gulp result)?

我应该在资产文件夹(在服务器上使用“gulp”)或公共文件夹(gulp 结果)推送时包含哪一个?

Any generated content should not, if possible, be included in a git repo (and pushed)

如果可能,任何生成的内容都不应包含在 git repo 中(并推送)

If you can have a post-receive hook on the server side which executes gulp for you, that would be best.
That being said, this isn't always possible, and on a production server, adding gulp might not be always possible. In that case, versionning the generated content is acceptable.

如果您可以在服务器端有一个 post-receive hook 来为您执行 gulp,那将是最好的。
话虽如此,这并不总是可行的,并且在生产服务器上,添加 gulp 可能并不总是可行的。在这种情况下,对生成的内容进行版本控制是可以接受的。

回答by Hiram

First, you can add Laravel default .gitignore content: https://github.com/laravel/laravel/blob/master/.gitignore

首先,你可以添加 Laravel 默认的 .gitignore 内容:https: //github.com/laravel/laravel/blob/master/.gitignore

And add your js,css directory to .gitignore like this:

并将您的 js,css 目录添加到 .gitignore 中,如下所示:

/public/css
/public/js

Check it:

核实:

cat .gitignore

/vendor
/node_modules
Homestead.yaml
Homestead.json
.env
/public/css/
/public/js/

回答by James Flight

In an ideal world, you don't want to push generated files to your repository/production server. One reason for this, is that adding constantly changing versions of generated files can cause irritating issues when using git in collaboration with others.

在理想的世界中,您不希望将生成的文件推送到您的存储库/生产服务器。这样做的一个原因是,在与其他人协作使用 git 时,添加不断变化的生成文件版本可能会导致恼人的问题。

However, every project's situation is different, and sometimes it is easier to version the generated files and to deploy them this way. Particularly if you are working independently of others on the project, there is no real issue with this.

但是,每个项目的情况都不同,有时对生成的文件进行版本化并以这种方式部署它们会更容易。特别是如果您在项目中独立于其他人工作,则没有真正的问题。