在 CakePHP 项目中使用 Git
我使用 git 作为我的主要版本控制系统,并且最近开始在我的 CakePHP 项目中使用 git。这是我当前的 .gitignore 文件:
app/tmp
vendors/
与 cakephp git 存储库中使用的一样,但这在将项目部署到服务器时会给我带来更多工作,因为我必须进入并创建所有 app/tmp/ 子目录在它们正常工作之前必须手动操作。有没有办法将其设置为忽略这些文件夹上的内容,但仍将它们置于 git 控制之下,以便当我将存储库克隆到 hoted 目录中时它们会出现?
我在处理 git 索引时也遇到了重置问题,这导致我必须做比必要的更多的提交,对此还有什么想法吗?
I use git as my primary version control system, and have recently started using git on my CakePHP projects. This is my current .gitignore file:
app/tmp
vendors/
As used in the cakephp git repo, but this causes a bit more work for me when deploying the project to a server, because I have to go in and create all the app/tmp/ sub-directories by hand before they will work correctly. Is there a way to set it up to ignore the contents on these folders, but to still have them under git control so they appear when I clone the repo into the hoted directory?
I also have been having an issue with my git index being reset while I am working on it, which is causing me to have to do a lot more commits than should be necessary, any ideas on that also?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Git 仅存储文件,而不存储目录,因此您可以将隐藏文件添加到该目录中并提交它。
Git stores only files, not directories, so you can for example add a hidden file into that directory and commit it.
正如前面提到的,git 只存储文件,而不存储目录。默认情况下,cake 的 .gitignore 文件会忽略 tmp 文件夹中的所有内容,以防止 tmp 文件添加到存储库中。
但是,您可以(并且应该)在创建项目后执行此操作:
这将执行以下操作:
因此您的 tmp 文件夹结构已准备好提交,但 tmp 目录中的所有其他文件将(继续)被忽略。
As mentioned git only stores files, not directories. By default cake's .gitignore file ignores all contents in the tmp folder to prevent tmp files being added to your repository.
You can (and should) however do this after you create a project:
which will do this:
As such your tmp folder structure is ready to be committed, but all other files in your tmp dir will (continue to) be ignored.
我的 .gitignore 文件。
如果你注意到我有 !empty ,它可以让我免于在 SVN 之前创建 .keep 文件。最后,您还会看到我将此配置用于 [Cc] 指出的 cakePHP 1.x 和 2.x 项目。我设置了一些文件夹来存储用户文件,所以我也总是忽略它们。最后,.DS_Store 忽略了我的 MAC 为我的项目创建的缩略图视图。
My .gitignore file.
If you'll notice I have !empty which saves me from creating .keep files all over which is so SVN ago. Lastly you'll also see that I use this config for both cakePHP 1.x and 2.x projects noted by the [Cc]. I have some folders setup that I store user files in so I always ignore them as well. Finally the .DS_Store ignores my MAC created thumbnail views for my project.