LoginSignup
1
0

More than 3 years have passed since last update.

[Github初心者]ターミナルで新しいブランチを作成してマスターブランチとマージする方法

Last updated at Posted at 2020-07-27

掲示板を作成中、掲示板の基本機能のみ作ってherokuでデプロイした。
ユーザーログインという新規機能安全にデプロイする為に、新機能開発の前にあらかじめgitでmasterではないブランチを作って、テストを行ってからmasterブランチにmergeを行いたい。

ブランチ作成&そのブランチに切り替え

$ git checkout -b <任意のブランチ名>

Switched to a new branch 'create-users-table-model'

存在するブランチの確認コマンド

$ git branch

* create-users-table-model
  master

ブランチを切り替える

$ git checkout master

Switched to branch 'master'

git checkout create-users-table-model

Switched to branch 'create-users-table-model'

新しいDBテーブルの作成

$ rails g migration create_users

〜省略〜
warning: The called method `initialize' is defined here
      invoke  active_record
      create    db/migrate/20200727081835_create_users.rb

完成。

ここから開発を行っていく。

DBに必要カラムを追記して作成

db/migrate/'date'_create_users.rb
class CreateUsers < ActiveRecord::Migration[5.1]
  def change
    create_table :users do |t|
      t.string :username
      t.string :email
      t.timestamps #created_atなどが自動で追加される
      #passwordカラムはあとから追加する
    end
  end
end

userモデル作成

modelsフォルダの下にuser.rbを追加

models/user.rb
class User < ApplicationRecord

end

保存。$rails cでuserが作成できるか確認。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0