I just have done a git push
in our online repo
When I checked the online repo and checked the public
folder it shows this:
while in my local repo I have this in my public
folder:
My local has Storage folder from my storage link. I am guessing that this has something to do with the .gitignore
inside my local public
folder. It contains:
*
!.gitignore
Same goes with my storage folders. In our Online repo inside storage/app/public
:
while in my local storage
folder:
user_images
is present in my local repo. Here is the inner .gitignore
:
*
!.gitignore
and the outer .gitigore
:
*
!public/
!.gitignore
I am not quite familiar with setting rules in .gitignore
. I wish to make sure that whatever my local Storage and public folder has, the Online repo has as well. How should I go about in doing this?
Kindly edit my tags if it is misleading or incorrect. Thank you.
This is the content of the root .gitignore
:
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
I have removed /public/storage
in .gitignored
and tried to do a git push
Changes not staged for commit:
modified: .gitignore
and still, nothing is the same from my local to Online repo? Anything I might have missed?
Tried running git check-ignore -v path/to/file
In my root .gitignore
:
/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
If I ran git check-ignore -v public/hot
, it replies with .gitignore:2:/public/hot public/hot
but if I ran git check-ignore -v public/storage
, it doesn't respond with anything which it should because it is included in root .gitignore
I come to believe that this situation made it impossible for the public/storage/user_images
and storage/app/public/user_images
. Any help is needed.
I may have been viewing a wrong file or path all this time. But I can confirm that @VonC method helped me do a proper exclusion in gitignore
. Thanks.
EDIT:
Final gitignores so far
root .gitignore
:
/node_modules
# /public/hot
# /public/storage
/storage/*.key
/vendor
.env
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
storage\app.gitignore
# *
# !public/
!.gitignore
storage\app\public.gitignore
# *
!.gitignore
public\storage.gitignore
# *
!.gitignore
Just an additional info:
git check-ignore -v vendor
gives .gitignore:5:/vendor vendor
while git check-ignore -v /vendor
gives fatal: C:/Program Files/Git/vendor: 'C:/Program Files/Git/vendor' is outside repository
I'm not sure where git check-ignore -v
path points to.
Create a symbolic link Alternatively, you can also try fixing the issue without the need for SSH to the server. For Laravel 5 and above, you can use the Artisan :: call() method on the route or controller to execute Artisan commands without using a terminal. First, go to the route folder your-app-folder/routes/web.
use Illuminate\Support\Facades\Storage; $url = Storage::url('file.jpg'); When using the local driver, all files that should be publicly accessible should be placed in the storage/app/public directory. Furthermore, you should create a symbolic link at public/storage which points to the storage/app/public directory.
Steps: cd to your <project_root>/public directory and run rmdir storage - it will remove the link.
First, for any file ignore within a folder, type:
git check-ignore -v -- path/to/file
That will display exactly which .gitignore
is responsible for ignoring said file.
Second, the rule of gitignore is simple:
It is not possible to re-include a file if a parent directory of that file is excluded.
To exclude files (or all files) from a subfolder of an ignored folder f
, you would do:
f/**
!f/**/
!f/a/sub/folder/someFile.txt
Meaning: you need to whitelist folders first, before being able to exclude from gitignore files.
For those who might still be searching for an answer, edit the .gitignore files in storage/app and storage/app/public folders and remove the first 2 lines from each.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With