I'm having some deployment problems, due to Rails' tmp/cache/assets folder and git not ignoring tmp/* or tmp/. My entire .gitignore is:
*.rbc
*.sassc
.sass-cache
capybara-*.html
.rspec
/.bundle
/vendor/bundle
/log/*
/tmp/*
/db/*.sqlite3
/public/system/*
/coverage/
/spec/tmp/*
**.orig
rerun.txt
pickle-email-*.html
It's taken from GitHub gitignore repo. What can I do to fix it? I get tons of errors due to local changes (in the tmp/ folder) on my server, such as error: Your local changes to 'tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705' would be overwritten by merge. Aborting., so I can't deploy on my dev machine :(
Did you add the .gitignore after starting the project? If tmp/cache/assets/whatever already existed before you added the .gitignore, it'll still be in the repo.
Try a git rm -r tmp && git commit to remove the whole tmp directory from the repo.
Try deploying at this point to see if deployment works from a known-good state. If it still doesn't work, you know there is some other issue.
If everything works, new changes to tmp should no longer be picked up.
ALso, as #thenetimp points out, your current .gitignore will only ignore /tmp, but not something/tmp. I'm not sure if that's your intention or not.
remove the forward slash in front of /tmp/ it should be tmp/
Take a look at a sample .gitignore file at: https://github.com/github/gitignore/blob/master/Rails.gitignore
I also found a good article at http://www.wrel.de/gitignore-und-was-kommt-rein/ (German)
Related
I am currently trying iOS developing on my own and my project has now become quite large, so i want to git push to github just in case i screw up.
However, as i tried to git push, it always gives this
"large files are detected, File Pods/nighthawk-webrtc/lib/libWebRTC-8444-arm-intel-Release.a is 118.31 MB; this exceeds GitHub's file size limit of 100.00 MB"..
It is the local "nighthawk-webrtc-8444.podspec" that i have causes the problem.
I sort of thought it may have to do with the .gitignore file, because i include the PODS for push, so i have my .gitignore written as this
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
*.xccheckout
#CocoaPods
Pods
to exclude the Pods library. However it doesn't work. It still trying to git push the entire local nighthawk-webrtc-library to github and i still end up with the same error.
This nighthawk-webrtc-library is a pod spec created by a third part, when i run pod spec lint, it gives me the following validation errors:
-> nighthawk-webrtc (8444)
- ERROR | The name of the spec should match the name of the file.
- WARN | There was a problem validating the URL www.perch.co.
which i do not have idea whether it has anything to do with git push, but even if it has, i can't seem to edit it.
To be just clear: I wish to git push the local pod spec to the github, but i do not wish to git push the entire library like what the system is currently doing. Anyway to fix this?
Thanks a lot.
Although the files are git ignored, I'd bet you a dollar that you need to remove them from the local git, and them commit AND push that. Ignore changes are NOT RETRO-ACTIVE, i.e. if a file was added you need to remove it.
Drop to a shell and type:
git rm <FILE(S)>
OR use SourceTree/Tower or whatever you prefer
I'm new to git and rails. I checked out a rails project and had a bunch of log files come in with it. I wanted to remove the log files and add an entry into .gitignore to ignore contents of the log directory. I think I screwed up because when my colleague tried to checkout from master, his log directory didn't even get generated. I think instead of ignoring contents of the log file, I ignored the entire log directory. What's the best way to change this .gitignore file to only ignore log files NOT the log directory itself? Also I don't think I need all these things in the .gitignore. What's a nice clean and simple .gitignore for a rails project?
*.sublime-*
.bundle
db/*.sqlite3*
log/*.log
*.log
tmp/**/*
tmp/*
Gemfile.lock
doc/api
doc/app
*.swp
*~
.DS_Store
Thank you in advance.
Git ignores empty folders, in fact it doesn't really know they exist (it knows about trees pointing toward file contents). Since there is no file content to point to, there is no tree and hence git will not create a folder.
Common way around this is to add empty file within the folder. Convention is to name this file .keep. Add such file to the empty folder, add it to the index, commit and push and folder will be created on checkout.
So I tried everything
but to no avail
I keep getting the following error
"fatal: cannot use tmp/ as an exclude file"
I have even tried using /tmp and tmp/* but none of these two work either .
Finally I deleted the tmp folder in frustration and i found that git now works perfectly
SO I have two questions.
The obvious one being . How do I get this to work?
Is it possible for me to run my ruby on rails applications without the tmp folder?
The obvious one being . How do I get this to work?
Add /tmp to your .gitignore at the root of your Rails app. Make sure you add and commit this .gitignore before committing /tmp — you'd have to git rm it to make it disappear from the repository again.
Is it possible for me to run my ruby on rails applications without the tmp folder?
No. Why would you? Rails needs to be able to write files there in order to work properly. You can only symlink it somewhere else, but that won't really solve the issue if the files are included in your repository. See also: Rails3: Change location of temp (tmp) directory
It may have to do with the way git works with cached files that the folder may still show up after including it in the .gitignore file.
Try git rm . -r --cached in the command line to clear out the cached files.
I am using Ruby on Rails, the Capistrano gem and git. Long time ago I initialized git and in the .gitignore file I stated the following:
.bundle
db/*.sqlite3
log/*.log
tmp/
One day I created a sub-directory in the /public directory of my RoR application: /public/users/.... Now in the latter directory I have the following file system structure:
/public/users/001/file1.png
/public/users/001/file2.png
/public/users/001/file3.png
...
/public/users/002/file1.png
/public/users/002/file2.png
/public/users/002/file3.png
...
...
At this time git is tracking all file in the /public directory including all directories and files inside /public/users/. So, when I deploy with Capistrano, all those will be updated on the remote machine, as well.
What I would like to do is to do not track anymore public/users directories, subdirectories and files (on my local machine) so that on the remote machine those will be not updated. That is, I would like to make possible that when I deploy with Capistrano all that is related to the public/users (on the remote machine) is untouched.
How can I do that?
P.S.: I read a lot of other questions and answers (eg: 1, 2, ...) but all them seem do not work for me.
I am almost sure that I must add the following text line to the .gitignore file:
# Ignoring "public/users/" directories, sub-directories and files
public/users/
and then (if the above code is valid) what I should do?
Try to put all user related files into one folder , say system then
You can put public/system/*.* in git ignore..
then your dir structure would be :
public
->404.html
->js.../..,..,..
->css ../..,..,..
->system
->users
->1/something
->2/something
->some-other-user-related-info
Also why is there a need to put development related files into git and then to server ?? No point .. so do not do it.. It will increase your repo size for no reason.
Since you are using capistrano your server dir structure will look like this :
APP
->Current
->releases
->shared
your public/system folder will keep pointing to shared/system
case 1: files in users/ not committed
put all the user related file in .gitignore
case 2: if files have been commited
perform a git delete and then commit
then add it to .git ignore
I had a file I needed to edit in my .gitignore file.
I edited .gitignore, committed it, and still my file was unavailable to commit.
I deleted the file, readded it, and once it has the same name, its still unavailable to commit.
I tried -f, which then added an empty version of the file to my repository. And the worst apart about that is that if I deployed, it would break my entire application at this point.
Update:
The file I want to add is :
public/javascripts/ckeditor/config.js
my .gitignore file says :
public/stylesheets/*.css
*.swp
*.pid
.idea
config/database.yml
log/*.log
db/*.sqlite3
tmp/**/*
doc/api
doc/app
doc/plugins
public/system/*
coverage.data
coverage/*
.DS_STORE
.DS_Store
solr/data/**/*
solr/pids/**/*
config/initializers/mail_delivery_override.rb
Git status reveals this :
# On branch testing
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: public/javascripts/ckcustom.js
#
no changes added to commit (use "git add" and/or "git commit -a")
That ckcustom.js is a compiled file form the ckeditor suite that is made by other changes. But I can't just edit that file, I had to edit its inner workings.
Next time try:
git add -f path/to/ignore_file
Ok I'm pretty sure this worked, and this was really strange! Almost lost some dreadlocks over this one.
To begin, I logged in manually into my server, deleted the crappy file git had made. Recreated it, copied and pasted my file back in, and got my server back online.
Then I went to github.com and manually opened, edited, and committed the file right from the online API.
I readded the .gitignore file, and the ckcustom.js file, and the problem seems to be fixed.
Sheesh!