'Do I need to store on Github storage/framework/

I have a question about Laravel and Github. Do I need to ignore storage/framework path on .gitignore?

Example on my commit:

8 files changed, 754 insertions(+), 1 deletion(-)
 create mode 100644 storage/framework/sessions/zYkePpngbtn5GNPIRMEehGFvzeVppHrVXLqhOwA7
 create mode 100644 storage/framework/views/765841d09319f048f32d8882f6bbb3f08ec2c77e.php
 create mode 100644 storage/framework/views/81232a0454b4884e95fc761f2b83d91d58048257.php
 create mode 100644 storage/framework/views/897f7ec0ff9e6c3720ffb93c900c4071f8a9940e.php
 create mode 100644 storage/framework/views/b40ed3de06d25e0481dfd99f0a59c3684ae8bb72.php
 create mode 100644 storage/framework/views/c5d64eaf0170adba24fc01265d98e0fa3d78d799.php
 create mode 100644 storage/framework/views/d5dc694ee95860847f6c74f2b3e5b4a035544513.php

I'm also running on Heroku with this same Github.

Isn't it weird that these files are uploaded to the server? I'm learning I know maybe this is a stupid question

Thanks!

Update: This is my gitignore:


# Created by https://www.gitignore.io/api/laravel

### Laravel ###
vendor/
node_modules/
npm-debug.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json

# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/
storage/*

2update: When I add storage/ to .gitignore I got the following message on the server (Heroku):

ErrorException:
file_put_contents(/app/storage/framework/sessions/B1m3t7iCFictcEFsYXMTSqm4f7pQM2BWlJIa2G3H): Failed to open stream: No such file or directory

  at /app/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:187
  at Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
     (/app/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php:231)
  at Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap\{closure}()
  at file_put_contents()```


Solution 1:[1]

You don't want to ignore the folders in the storage folder, as they are part of your application. You're just trying to ignore the temporary files that are generated in those folders. You'll want to do what the base Laravel install does. Don't add the folders to your base .gitignore file, but create new .gitignore files inside the folders that ignore all files except for that .gitignore file.

So, for example, in your storage/framework/sessions folder, you should have a .gitignore file with the following content:

*
!.gitignore

This says "ignore everything in this directory, except the .gitignore file".

With this setup, your storage/framework/sessions folder will be committed to your repo, along with the .gitignore file inside of it, but no other files in this directory will ever be committed.

Solution 2:[2]

Actually, default Laravel's gitignore should be sufficient but here is my gitignore that I developed over for my projects.

vendor/
!public/vendor
node_modules/
npm-debug.log
.php_cs.cache

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
storage/clockwork
.env.*.php
.env.php
.env
.env-production
Homestead.yaml
Homestead.json
.phpunit.result.cache
coverage/**

# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/

# Phpstorm
.idea
_ide_helper.php
_ide_helper_models.php
.phpstorm.meta.php
.DS_Store
app/Repositories/Interfaces/UserRepositoryInterface
app/Repositories/UserRepository
App\Repositories\UserRepository
App\Repositories\Interfaces\UserRepositoryInterface
# Elastic Beanstalk Files
.elasticbeanstalk/*
!.elasticbeanstalk/*.cfg.yml
!.elasticbeanstalk/*.global.yml
storage/app/*
/tmp/
.vscode/settings.json
.php-cs-fixer.cache

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 patricus
Solution 2 gguney