I'd like to split up rails using a git submodule, which as far as I can tell, works basically like a directory. While this works well with a file structure similar to Python's Django, where each module has a models.py, views.py, etc, this doesn't appear to work so well with rails, which gives you a directory structure where there is a views folder, a controllers folder, etc, with each folder having 1 file from the module.
Is there any way to convert to a file structure similar to Django's, or if not, how would you use git submodules with rails?
how would you use git submodules with rails?
You would not use them, not directly at least. A git submodule is a repo, checked out in its own folder.
If you couple it with a deployment script which would linked (symlink) files from the rails directory structure to the files from that submodule folder, then you could get a rail app.
Related
I made a Rails application.
Do i need to push these files to Github?
.browserslistrc
.gitattributes
.rspec
.ruby-version
The short answers are "if you want", and "there's no reason not to".
All of these files do something to make it easier to replicate your code base and setup on another machine. None of them contain secrets that shouldn't be shared.
.browserslistrc
The config to share target browsers and Node.js versions between different front-end tools.
.gitattributes
a simple text file that gives attributes to pathnames.
These attributes affect how the contents stored in the repository are copied to the working tree files when commands such as git switch, git checkout and git merge run. They also affect how Git stores the contents you prepare in the working tree in the repository upon git add and git commit.
.rspec
Read command line configuration options from files
.ruby-version
Many Ruby (or Rails) projects will include a simple .ruby-version file, which simply specifies a version number
I have a generator that creates some view files.
I'm wondering about the extensibility of the generator - if there is a change in the generator template file, do I need to modify the existing files which were created by the generator manually?
I know that I can overwrite the existing files by running the generator command. But if I have edited the file after the file generation, overwriting can remove some necessary parts.
What is the best method to apply the latest generator template in the existing file?
Run the generator and then use git to determine which parts of the change to the generated views you want to keep.
You can do this through the command line using git add -p to stage certain parts of files before you commit (From Git Tools - Interactive Staging).
Any decent git GUI would also allow you to stage changes in this way too.
I am using git with Xcode but when i commit files using Xcode (not command line) after committing and pushing to remote, when i use git status this is the result.
What are Untracked Files. What should i do with them?
And what about Changes not staged for commit part? What are they?
These untracked files are files that have been added to your directory structure (e.g. it would appear that you did a pod install), but you have neither added them to source control nor told git to ignore them. (I would tell git to ignore them, personally.)
But you have to decide whether you want to add the Pods directory to your repo or whether you'd like to ignore them. See https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control. (I personally don't put Pods into source control, just the Podfile and Podfile.lock. There are many opinions on that topic, though.)
Re the .DS_Store, we often have a ~/.gitignore_global that tells it to ignore those, too. Once you tell it to ignore these, they will be removed from the “untracked” files list. See .gitignore all the .DS_Store files in every folder and subfolder.
Re the unstaged .DS_Store it looks like your repo already had that one .DS_Store in the repo. I would suggest removing it from the repo. See How can I Remove .DS_Store files from a Git repository?.
In short, it looks like you have a project with no .gitignore file (or it is missing entries). It also looks like you don’t have a ~/.gitignore_global to ignore .DS_Store files.
For an example of a .gitignore that you might use for Swift projects, see https://github.com/github/gitignore/blob/master/Swift.gitignore (though, like I said, I generally would uncomment the Pods from that particular .gitignore).
I had not heard of this file until I randomly checked git status in an old repository and there it was, a file I had not edited myself nor ever seen before. I do not know how it got there.
It seems it's common asked about - mostly how to remove it (e.g. here and here).
What is this file, and what created it?
.idea is the dir for saving the project configurations for all Jetbrains IDES (RubyMine , Pycharm , PHPStorm , WebStorm ..etc)
you can handle it using two ways if you don't want to commit it to the repo
Ignore it only for yourself
in .git/info/exclude
add /.idea
Ignore it in .gitignore so it will be ignored for everyone who uses the repo
by adding /.idea to .gitignore
if the dir .idea already tracked by git you will need to remove it first from the cached files before ignoring by git rm -r --cached .idea
This folder can include important configuration if you did any custom configuration for the project and also include the indexed data for the IDE which helps it to provide quick autocomplete and in certain cases would be better to commit it to the repo but I always ignore it because the other developers in the team don't use RubyMinee
How can I add a folder recursively, with its subfolders and its files?
When I use git add folder_name, only that folder is getting added. git status now shows the files under the subfolders are shown as new files and untracked.
For example, in Rails application, inside the Rails project folder, there are many folders:
app
public
db
script
vendor
etc.
Is there a better way to add a rails project to git?
cd desired_directory; git add .;
Er, it looks like this was answered by Justin L. in a comment while I as typing.