0

In my Git repository, for security reasons, I do not have the .env file; however, in the production environment, this file already exists at the root and is configured (and it's not versioned). My goal is that when I deploy to Cloudways, this production file is retained, and I don't have to reconfigure it again with each deployment.

However, when I perform the pull via Cloudways, this production file gets deleted. How can I prevent Git from deleting it?

Paulo Costa
  • 182
  • 3
  • 12
  • Does this answer your question? [How to prevent Git pull from deleting local files](https://stackoverflow.com/questions/55324083/how-to-prevent-git-pull-from-deleting-local-files) – Brad Jul 16 '23 at 02:49

1 Answers1

1

In such cases, I prefer to keep the "to be retained" files in a different folder - and as part of your deployment process, you can create symbolic links once the code has been deployed into appropriate folders. For eg (concept-wise), this is how capistrano manages different releases.

<app installation folder>
 |
 |- release1 # date + time-stamped folder names
 |- release2
 |- .
 |- .
 |- .
 |- current # symbolic link to the appropriate release folder
     |- configFile # symlink from ../shared/<file>
 |- shared # folder where the common files can live irrespective of which is the current release

In the above example, your file (that should not change across releases) can go into the shared folder.