Skip to content

Instantly share code, notes, and snippets.

@vnoitkumar
Last active July 22, 2020 14:07
Show Gist options
  • Save vnoitkumar/fdc89f546a8becc9761d16167cb8b815 to your computer and use it in GitHub Desktop.
Save vnoitkumar/fdc89f546a8becc9761d16167cb8b815 to your computer and use it in GitHub Desktop.
Add gitignore in Laravel 5.* Project
# WARNING: You have to clear the git cache somtimes for reflecting the .gitignore in you project
# For that I have cleared the full repo git cache with "git rm -r --cached ."
# If you like you can clear the cache for indujual folder after adding the .gitignore file.
# REFERENCE: Laravel official repo with approriate version
# https://github.com/laravel/laravel/tree/5.5
mkdir -p storage # create logs directory if not exist
cd storage
mkdir -p logs # create logs directory if not exist
mkdir -p framework # create framework directory if not exist
cd framework
mkdir -p cache # create cache directory if not exist
mkdir -p sessions # create sessions directory if not exist
mkdir -p views # create views directory if not exist
cd ../..
# clear all the cache
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear
rm -f storage/framework/sessions/* # clear sessions
printf "/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log" > .gitignore
cd storage/framework/
printf "config.php
routes.php
schedule-*
compiled.php
services.json
events.scanned.php
routes.scanned.php
down" > .gitignore
cd cache/
printf "*
%c.gitignore" ! > .gitignore
cd .. && cd sessions
printf "*
%c.gitignore" ! > .gitignore
cd .. && cd views
printf "*
%c.gitignore" ! > .gitignore
cd ../.. && cd logs
printf "*
%c.gitignore" ! > .gitignore
cd ../.. && cd bootstrap/cache
printf "*
%c.gitignore" ! > .gitignore
cd ../.. && cd public/
printf "/uploads
/contus" > .gitignore
cd ..
# git rm -r --cached . # Clear git local cache
chmod -R 777 bootstrap storage public
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment