Is the .gitignore file universal/global, in Rails? - ruby-on-rails-3

I'm a noob to RoR, so any help/clarification is appreciated.
Is the .gitignore file in Rails universal/global to all of Rails, or does each project/app have its own .gitignore?

.gitignore is a Git file, it has nothing to do with Rails.
A .gitignore file will apply to the directory it is in and any subdirectories. You can create .gitignore files in subdirectories to have them only apply to those subdirectories and their descendants.

A default .gitignore is created when you create a new Rails app. That file tells git to ignore the things that are in a default Rails app that should probably be ignored.
If there are other files that should be ignored in your specific app, you can make changes to the .gitignore. If you're not using git, you can delete the file entirely.
It's basically there to encourage best practices, but is in no way required to run a Rails app.

There's a .gitignore_global file in your ~/ directory that every git instance references.
Git is independent of rails.
the .gitignore file is restricted to the initialized repository.

Related

Nuxt - Purpose of README.md in each folder in the default project structure

I wonder why there is a README.md in every folder in the default project structure. Is it intended to keep it?
Answer from the Nuxt Discord: Create-nuxt-app only recently made git optional, but it was automatically added previously. AFAIK git can't track empty directories, thus they used README.md to mitigate this. Other solutions I've seen are creating files like .gitignore or .gitkeep inside a empty directory to ensure the empty directory is tracked/commited. It can be any name, but gitkeep seems to be what people gravitated to, yet I never did this personally.

should I add app.js file in gitignore for nodejs/vuejs app?

I am new to vuejs. Recently I noticed that when I pull, it says conflict in app.js file. But I can't find the issue as app.js file is big.
Sould I add this file to gitignore file?
what is best practice to work with vue js?
I imagine you are building to a folder /dist and the app.js being conflited is the one inside of it.
You should ignore the /dist altogether. This folder is generated on the building process, meaning everyone that runs the project will update and create it.
Here is the default vue-cli .gitignore:
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
Not that not anything here may be useful to put in your own .gitignore. But you should for sure have at least node_modules and /dist.
If you are building the Vue project by scratch then I can say the following, when building/compiling your Vue project, best practices say that you should handle your entire production ready project in a dist/ or build/ directory where your main app.js file where the conflicts you are having would occur. This directory is only reserved for deploying the app and is not saved into your code repository, hence on why you should add to the .gitignore file the directory that holds such production files.

PhpStorm automatically ignore files from .gitignore

I'm new to PhpStorm, and I'm trying to get it to automatically ignore files specified in my .gitignore file when adding a file tree to git. I know you can add ignore rules to PhpStorm itself, but I want it to use the rules from my .gitignore file.
Basically I already have a .gitignore file with ignore rules, I just want PhpStorm to follow those rules when adding files (git add) so that none of the files matching the .gitignore rules will be accidentally added to a commit.
I know in the past this has happened to me as well, so it seems a bit fragile. I never do a git add for the entire directory since it has done things like add files in the /vendor directory (which is always in the gitignore file).
But having said that, I was curious, so I did a test as I think it might be related to when things happen (like when git is engaged, or when the .gitignore is added).
I did the following steps on a new project and it worked appropriately, so maybe that will help, you can give it a try and see if it works for you as well. I am working with 2016.1.2
Create the project
Select VCS...Enable Version Control Integration and select Git
Create the .gitignore in the root directory
In the project, create a new directory called ignore
In the .gitignore, add ignore/ and the ignore directory should turn light gray
Create a.txt in the root directory
create b.txt in the /ignore directory
right click on whole project and select git add and b.txt under the ignore directory is not added, but a.txt is

GIT ignoring files in project/bin/debug folder except few files (Visual Studio Project)

This is how my .gitignore looks like:
# User-specific files
*.userprefs
!*.ini
!*.gitkeep
!*.bat
# Build results
[Bb]in/
[Dd]ebug/
What I want to achieve is to ignore all files in project/bin/debug but keep the files like *.ini *.bat and etc.
.gitignore is location in root folder:
rootfolder\project name\bin\Debug
This works well for me. Add wildcard to your folders, and define the exceptions at the bottom.
# Build results
[Bb]in/*
[Dd]ebug/*
# User-specific files
*.userprefs
!*.ini
!*.gitkeep
!*.bat
Use ! operator to negate pattern:
*.bat
!myfile.bat
In your case it's better to use .gitignore in specific directory. You should make .gitignore file in project/bin/debug with a content:
*.*
!*.bat
Or you can do it in your project main .gitignore:
MyFolder/*
!MyFolder/NotIgnored.txt
Without * it won't work.
Keep in mind that already staged files won't be ignored. You need to unstage them using git rm --cached <file>
I solved this by modifying the .gitignore of my root folder to:
# User-specific files
*.userprefs
!*.ini
# Build results
![Bb]in/
[Bb]in/*
![Dd]ebug/
Then creating another .gitignore file inside rootfolder/project/bin/debug/ directory with the ff:
*
!*.ini
!*.bat
Hope this can help someone in the future.
And btw, I got my .gitignore file from: https://www.gitignore.io/api/visualstudio

Git and XCode: Merging .xcodeproj gives binary warning

I am working with branches and wanting to merge with my master, but the files inside of my .xcodeproj are causing huge issues.
Constantly getting errors about overriding them, that they are binary files, etc etc.
What do I need to do to never have to worry about this? It is driving me nuts!
NOTE: I have a .gitignore file in my master that ignores these files, but not in my branch. Not sure what to do about that.
In the root of the project (eg, same directory as .git), add a git ignore file
.gitignore
With a line that says
.xcodeproj
Then remove the .xcodeproj file from the repo...
git rm --cached /path/to/.xcodeproj
Then add the .gitignore file
git add .gitignore
Then commit
git commit -m "Removed .xcodeproj; added ignore pattern to excluded it"
You can use a .gitignore file to specify that file to be ignored by git.