I will divide it into several times and write a series from application creation to deployment with the Rails new command. The first time, I will write from Rails application template creation to push to a remote repository.
I would be grateful if you could let me know if there are any missing points or mistakes.
Development environment Language: Ruby 2.5.1 FW:Ruby on Rails 5.2.4 DB:PostgreSQL test:RSpec Version control: Git, GitHub
Environment: MacBook Air
Create a directory for your application using the Rails new command!
Terminal.
rails new <App_name> -option
Actually I wanted to use PostgreSQL for the DB, so I entered the following command and incorporated it into the application first. (Can be changed later)
Terminal.
rails new App_name -d postgresql
This will create the directories needed for your Rails application.
After creating, use the cd command to move from the current directory to the directory you created earlier.
Terminal.
cd App_name
Now, let's create a DB!
Terminal.
rails db:create
This will create the DB.
Terminal.
rails s
Launch Rails server http://localhost:3000 Access from your browser!
Did you confirm that the server started up correctly? By the way, you can end it with control + c.
Get started with Git!
Terminal.
git init
Now you're ready to manage Git. Git related directories are set as hidden directories, so you may want to visualize them with command + shift +.
Stage your application I usually check the status (git status) and diff (git diff) before staging, but I will omit it. (Check the status of the changed file)
Terminal.
git add .
Stage all modified files with add. (Dot). In this case, all the files created by Rails new!
Terminal.
git commit -m "first commit"
Record your changes with the command above! The -m after commit is optional and is an option to leave a comment! It's always decided to leave a comment when committing, so add it so you can understand what you've changed.
After creating a remote repository on GitHub
Terminal.
git push
I get angry when I hit. In short, I don't know where to connect to the remote repository, so I'll tell you. (In addition to being angry, you will be asked to enter the following command)
Terminal.
git remote add <name> <url>
If you write it like an actual command ↓
Terminal.
git remote origin https://github.com/×××
This is OK The rest is pushed with the following command.
Terminal.
git push -u origin master
The above command is used only for the first time, but after the second time, just git push is OK! The same is true when cutting a branch.
That's all for this time. I wrote it as a memorandum for myself, Thank you for visiting!
Recommended Posts