Using Git to Track Ruby on Rails
Besides the database and log files, are there other files that should not be in the repository for security reasons?
Most of the time the project will run on its own, but the code must be kept in a shared repository that will be available to a few other users if they want to check out. The project is simple enough so I don't worry too much about security in my actual code - it's more for protecting any test data, etc. And to create "good practice" in this type of project.
a source to share
A typical .gitignore
file in the context of "ruby on rails" might look something like this:
config/database.yml
db/*.sqlite3
log/*.log
log/*.pid
tmp/**/*"
But as stated in the article " rorgitignore: .gitignore Ruby on Rails specific files ", you can also use .gitignore
add empty directories.
Since git is tracking content, not files, it does not keep any empty directories since there is no content to track.
This means that when you clone your project from the repository
git
, it is notlog
,tmp
,lib
and other directories.This little script fixes it so it
git
even adds empty directories
for DIR in `find . -type d | sed -re 's/\.\///g' | grep -v '^\.git'`; do
[ `ls -a $DIR | wc -l` -le 2 ] && \
echo Creating and git-adding $DIR/.gitignore && \
touch $DIR/.gitignore && \
git add -f $DIR/.gitignore
done
this just outputs the commands to add an empty file
.gitignore
to all empty project directoriesgit
andgit add -f
'em in the repo.
If you're still only focusing on the main .gitignore file, here's a more complete one, from iCoreTech Research Labs
config/database.yml
*~
*.cache
*.log
*.pid
tmp/**/*
.DS\_Store
db/cstore/**
doc/api
doc/app
doc/plugins
coverage/*
db/*.sqlite3
*.tmproj
Capfile
a source to share