Skip to content

Instantly share code, notes, and snippets.

@caasig
Forked from tijmenb/cakegittmpdirs
Last active August 29, 2015 14:25
Show Gist options
  • Save caasig/77540be2a48a6b34297a to your computer and use it in GitHub Desktop.
Save caasig/77540be2a48a6b34297a to your computer and use it in GitHub Desktop.
Regenerate and commit CakePHP 2.x tmp dirs. To use this for 3.x just update the logs dir paths
#!/bin/bash
# Based on: http://stackoverflow.com/questions/2218075/using-git-with-your-cakephp-project
# MAKE SURE you commit any changes you want to keep before running this!
#
# Usage:
# 1. Drop this bash script into the same level as tmp/
# 2. cd path/to/this && ./cakegittmpdirs
# Procedure:
# 1. Remove tmp/ from .gitignore
# 2. touch tmp/empty
# 3. git add tmp/empty
# 4. git commit
# 5. Add tmp/ to .gitignore
# Clean tmpfiles and delete .gitignore
rm .gitignore
rm -rf tmp
# Set up directories
mkdir -p tmp/cache/models
mkdir -p tmp/cache/persistent
mkdir -p tmp/cache/views
mkdir -p tmp/logs
mkdir -p tmp/sessions
mkdir -p tmp/tests
# Make the directories itself writeable
chmod -R 777 tmp
# Add empty files to the directories
touch tmp/cache/models/empty
touch tmp/cache/persistent/empty
touch tmp/cache/views/empty
touch tmp/logs/empty
touch tmp/sessions/empty
touch tmp/tests/empty
# Add all files to stage
git add tmp/*
# Commit the changes
git commit -m "Set up tmp dirs"
# Undo gitignore
git checkout -- .gitignore
# done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment