ブランチ切り替え時にschema.rbに差分がある場合の対処
ファイルの状態によって対処する
schema.rbのみ
schema.rbの変更を破棄する
code: (sh)
git checkout -- db/schema.rb
git switch -c new_branch_name
schema.rbはマイグレーションの副産物で自動で生成される
自動で生成されるファイル = 再生成できる
schema.rbを削除、破棄してもrails db:migrate で再生成可能
schema.rb以外に変更ファイル有り
stashで変更を退避する
code: (sh)
git stash push -m "stash message."
git switch -c new_branch_name
git stash apply
or
git stash pop
schema.rb以外に変更ファイルは退避させておくのがベター
stash時にメッセージを追加すると分かりやすい
ブランチに戻ってきたらstashを復元する