没有不值得去解决的问题,也没有不值得去学习的技术!

Edit .gitignore to Ignore UUID-Based Directories

Edit .gitignore, located at the same level as the public directory, to add directories to be ignored (directory names are unknown). Some directories will be generated under the public directory, and all of these directories should be ignored

1. Edit .gitignore, located at the same level as the public directory, to add directories to be ignored (directory names are unknown). Some directories will be generated under the public directory, and all of these directories should be ignored. See Figure 1.

Edit .gitignore, located at the same level as the public directory, to add directories to be ignored (directory names are unknown). Some directories will be generated under the public directory, and all of these directories should be ignored
Figure 1

2. View the current content, all entries starting with /public/

Plaintext

/public/certificate_sandbox.*
/public/.well-known
/public/hot
/public/storage
/public/js
/public/global
/public/chunk
/public/default
/public/css
/public/venue
/public/showtime
/public/vogue
/public/athena
/public/checkout
/public/fonts
/public/iconfont
/public/images
/public/12345
/public/*.js
/public/*.js.LICENSE.txt
/public/mix-manifest.json
/public/nginx.htaccess

# /public/fonts
/public/vendor

/public/page-cache/


3. View the committed files under the public directory in GitLab that are not ignored. See Figure 2.

View the committed files under the public directory in GitLab that are not ignored
Figure 2

4. We cannot explicitly specify the directory names under public now, because these directory names (in UUID format) are automatically generated at program runtime.

5. Therefore, we can only explicitly define which files under the public directory should not be ignored. Refer to the ignored files section in: https://git-scm.com/book/zh/v2/Git-%E5%9F%BA%E7%A1%80-%E8%AE%B0%E5%BD%95%E6%AF%8F%E6%AC%A1%E6%9B%B4%E6%96%B0%E5%88%B0%E4%BB%93%E5%BA%93 . First ignore all files under the /public directory, and then add exceptions. Adjust it as follows:

Plaintext

/public/*
!/public/modules
!/public/appcode.png
!/public/domain.txt
!/public/favicon.ico
!/public/index.php
!/public/logo.png
!/public/robots.pages.txt
!/public/robots.txt
!/public/tracking-api.js
!/public/web.config

6. Create new files /public/1.php and /public/modules/2.php. Upon committing, we find that only the file /public/modules/2.php is committed, and some UUID-generated directories have been ignored. This matches expectations. If new directories or files under the /public directory need to be committed later, you must add ! to confirm they should be tracked. See Figure 3.

Create new files /public/1.php and /public/modules/2.php. Upon committing, we find that only the file /public/modules/2.php is committed, and some UUID-generated directories have been ignored. This matches expectations. If new directories or files under the /public directory need to be committed later, you must add ! to confirm they should be tracked
Figure 3

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系