Using Git to track Ruby on rails
Other than the database and log files are there any other files that should not be in the repository for security reasons?
The project will mostly be worked on by myself however the code is to be stored on a shared repository which will be available to a few other users should they want to pull from it. The project is reasonably simple, so i am not too worried about security in my actual code – this is more to protect any test data etc and to build up ‘good practice’ in this type of project.
- Subversion adding unversioned project files to working copy
- NetBeans and Java: what to add to version control?
- git repo config for multiple environments
- What are some concrete business cases for a CVS to Git migration?
- Is rebase and merge the same thing? Why are there 2 different procedures to do one thing?
- Android studio shelved changes disappeared, not even in the .idea/shelf directory
One Solution collect form web for “Using Git to track Ruby on rails”
.gitignore file in a “ruby on rails” context could look something like:
config/database.yml db/*.sqlite3 log/*.log log/*.pid tmp/**/*"
But, as pointed out by the article “rorgitignore : .gitignore files specific for Ruby on Rails”, you can also use
.gitignore to add empty directories.
Because git tracks contents, not files, it doesn’t save any empty
directories, since there is no content to track.
This means that when you clone your project from a
gitrepository, it is
liband other directories.
This small script fixes that, so
gitadds even 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
.gitignorefile to all empty directories in a
git add -f’em to the repo.
If you are still focused only on the main .gitignore file, here is 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