问题描述
在本地计算机和 AWS 代码提交存储库中有一个名为 profileimg 的文件夹。当用户上传图像时,该文件夹会填充图像。但是,当我更改本地计算机存储库中的一些代码并将 git push 放入远程存储库 (AWS codecommit repo) 时,带有空数据和图像的 profileimg 文件夹覆盖将消失。这是一个托管在 AWS beanstalk 环境中的 Laravel 8 项目。
到目前为止我在本地 git repo 中的尝试:
- $ git rm -r --cached public/images/profileimg/*
- $ git update-index --assume-unchanged public/images/profileimg/*
文件夹结构:
.gitignore
#exclude everything
public/images/profileimg/*
public/images/profiLeverifyDoc/*
#exception
!public/images/profileimg/.gitkeep
!public/images/profiLeverifyDoc/.gitkeep
此外,我在 AWS codecommit repo 中创建了 .ebignore 文件。本地计算机也有 .gitignore 文件。任何建议,请。
解决方法
在 profileimg 中创建一个名为 .gitkeep 的空文件,然后在您的 .gitignore 文件中写入:
# exclude everything
profileimg/*
# exception to the rule
!profileimg/.gitkeep
,
profileimg 文件夹用于存储随时间变化的用户图像。当我向代码库添加新更改并将它们推送到 AWS Beanstalk 环境时,现有文件和文件夹将被新更改替换。解决方案是创建一个 S 3 存储桶或将图像保存在单独的位置。
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/concepts.concepts.design.html