LoginSignup
0
0

More than 1 year has passed since last update.

git 、DB関連コマンド

Last updated at Posted at 2023-01-07

自分で使ってて検索するのが時間かかるので、こちらに書きます。

ブランチの作成

git branch [ブランチ名]
ブランチを作成するときは基本的に元のマスターブランチに戻る。

ブランチの移動

git checkout [ブランチ名]
-bオプションでブランチの作成と移動

git remote -v

リモートリポジトリのURLを確認

git branch -a でブランチが出てこないとき

最初に何もコミットしていないと出てこないときがあるので、現在の変更をコミットする

git stash

退避したい変更をaddしてgit stash
git stash list
で[stash]のIDを見て、下のコマンドでstashの取り出しをする
git stash apply [stash]

git reset

gitのコミットを取り消してgit hubの余分な差分を消す

git logやgithub上で戻りたいコミットのハッシュを探す

git reset --hard (ハッシュ値)

で変更内容もコミットも消す。

git reset --soft HEAD^

で変更内容は消さないがコミットは消す。

DBのリセット

rails db:migrate:reset
rails db:seed

DBに入ってテーブル更新

rails db
pass:root

テーブル確認

show tables
select * from (テーブル名)

DBのアップデート

UPDATE shops SET latitude = 35.689360, longitude = 139.692446 WHERE id=2;

参考URL
https://qiita.com/chihiro/items/f373873d5c2dfbd03250

0
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
0
0