accidentally removed log folder in rails .gitignore, log folder not being generated on pull request - ruby-on-rails

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.

Related

Unknown filename appears on hierarchical while commiting

I do not understand one file which is not on git repository & not on local repository (not even local & physical folder) but while I am going to commiting or push it seems in files hierarachical? By unchecking this file I am able push & pull code properly but I am curious to find what is the exact issue.
.DS_Store is a hidden file, which is created by MacOS to store the information about the containing folder. You should add this file to your .gitignore, so the git will never display it in your untracked/modified list.
According to wikipedia:
In the Apple macOS operating system, .DS_Store is a file that stores
custom attributes of its containing folder, such as the position of
icons or the choice of a background image. The name is an
abbreviation of Desktop Services Store, reflecting its purpose. It
is created and maintained by the Finder application in every folder
It seems you have changed filename EditOrNewAddressVuewController.m to EditOrNewAddressVuewController~.mthat is saved this info in .DS_Store & you pushed code to remote thereafter this because that .DS_Store info there is untracked file appears on you Git working tree hierarchy,
If you don't like this untracked file,delete .DS_Store add .gitignore file. Helpful link1, link2,link3
Even if, there is one silly way for avoiding to watch this,Clone project in another folder ;)
.DS_Store is MacOS system file that will appear in each directory for default HFS+ filesystem. Your Finder most likely is not dispaying hidden files (with dot prefix). You can setup .gitignore not to include .DS_Store, details here

Is it possible to put bower.json outside root folder?

When defining a package, Is it possible to put the bower.json file inside a subdirectory of my git repository, and reference it in other projects?
I know that the docs says to put it in the root, but I already have my own directory structure on my git repository and want to put it inside a subdirectory.
I'm wondering if exists an option inside .bowerrc file to configure bower.json location. That would solve my problem.
I know this question is pretty old but none of the answers address the OP's actual question.
It is possible to store your bower.json in a subdirectory of your project (or another project for that matter).
In your .bowerrc, use the cwd (current working directory) setting to specify where your json file is stored.
More info can be found in the bower configuration docs.
Bower will create the ./bower_components folder next to the bower.json file.
So, as long as you ensure that the paths of the js/css files are OK, you can put the components wherever you want.
In my case, I have to use different versions/dependencies for an HTML5 mobile app and a Bootstrap/Angular backend. So I have something like that:
/bower.json
/bower_components/
/app/bower.json
/app/bower_components/
Just be sure to include your bower.json files in the GIT tree and add the bower_components folders to the .gitignore file
Hope it helps

I cannot get git to ignore my tmp folder of my Ruby on Rails project

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.

Unable to create a snapshot in Xcode 4

When I'm trying to create a new snapshot, it ends with this message:
The following paths are ignored by one of your .gitignore files: /Users/path/to/project/.svn
Use -f if you really want to add them.
fatal: no files added
Every other topic I've finded is about similar problem with .DS_Store files. I've found 3 .gitignore files in project directories, but none of then contains .svn
What can I do to make it work?

Ignoring directories, sub-directories and files after that those was initialized

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

Resources