3

I have a Laravel project in a Homestead Vagrant environment over Windows 10. I'm deploying the project to an Apache hosting service. For Laravel storage to work I create a link using php artisan storage:link, that creates a link in /public called storage with points to /storage/app/public. Each time I push changes to my origin master repository, the hosting automatically does a pull origin master for my project and when it happens the storage link changes to a directory. After that any uploaded photos are not found by the server and I have to delete the /public/storage directory to recreate the symlink.

I've created a .gitignore file in the public directory to avoid Git from changing anything for the link.

/public/.gitignore

storage 
!.gitignore

I expect the link remain intact each time Git pull takes place automatically in the server.

sajad abbasi
  • 1,988
  • 2
  • 22
  • 43

1 Answers1

1

Since the public/storage folder has tracked content, ignoring it won't have any effect.

That would work for a file:

 git update-index --skip-worktree -- afile

That should resists a git pull.
But you want to ignore a folder and that is not trivial.
It is best if you make sure storage is not tracked (versioned) in your repository in the first place.

The OP Ricardo Becerra Enríquez adds in the comments:

I contacted the hosting support and they told me that I should ignore the storage link and create the links wherever I need.

So I deleted the storage link that was already on Git, then pushed the changes, pulled again, created the link in the production and now it's working.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • `/public/storage` is not a folder, is a link to the folder `/storage/app/public` – Ricardo Becerra Enríquez Jul 06 '19 at 02:17
  • @RicardoBecerraEnríquez What version of Git for Windows are you using? The symklink should be preserved/restored, instead of being converted to a folder. – VonC Jul 06 '19 at 09:53
  • I have version 2.18.0.windows.1 in my development environment and version 2.0.0 in the production environment. – Ricardo Becerra Enríquez Jul 08 '19 at 00:20
  • @RicardoBecerraEnríquez If the production environment is a Windows with Git 2.0, I am not surprised. Any chance to test that with a Git 2.22? – VonC Jul 08 '19 at 04:28
  • Hi VonC, I contacted the hosting support and they told me that I should ignore the storage link and create the links whereever I need, so I deleted the storage link that was already on Git, then pushed the changes, pulled again, created the link in the production and now it's working. – Ricardo Becerra Enríquez Aug 09 '19 at 00:32
  • @RicardoBecerraEnríquez Thank you for this feedback. I have included your comment in the answer for more visibility. – VonC Aug 09 '19 at 05:04