LoginSignup
2
5

More than 5 years have passed since last update.

開発中に使うGitコマンド

Posted at

このページを読んでわかること

  • 開発のフェーズごとに使うGitコマンドすべて

実装前

  • リモートリポジトリを追加する
$ git remote add [ローカルに作成したいリモート名] [URL]

実装中

  • 自分がどこのブランチにいるかを確認する→ブランチの頭に"*"がついている
$ git branch
  • リモートのブランチも合わせて確認する
$ git branch -a
  • ブランチを作成する(自分の現在いるブランチと同じものを別名で作る)
$ git branch [ブランチ名]
  • リモートブランチをローカルにチェックアウトする(ブランチも作成したブランチに移動した状態になる)
$ git fetch
$ git checkout -b [ローカルに作成したブランチのブランチ名] remotes/[リモート名]/[リモートのブランチ名]
  • ブランチを移動する
$ git checkout [ブランチ名]
  • リモートの最新コードを取り込む
$ git fetch [リモート名]
$ git pull
  • リモートの最新コードをマージする
$ git fetch [リモート名]
$ git merge remotes/[リモート名]/[ブランチ名] 
  • ブランチの状態を確認する(コミットしていない変更やコンフリクトファイルなどを確認できる)
$ git status
  • ブランチを削除する
$ git branch -D [削除したいブランチ名]
  • 変更の入った状態を一時退避させる(コミットせずに他のブランチに移れるようになる)
$ git stash
  • stashしたものを確認する
$ git stash list
  • stashを削除する
$ git stash drop [stash]
  • stash内容を戻す
$ git stash apply [stash]

実装後

  • コミットする
$ git add .
$ git commit -m "コミットコメント"
  • リモート名を確認する(ローカルにクローンしているリモートリポジトリ一覧を見ることができる)
$ git remote -v
  • リモートリポジトリにプッシュする
$ git push [リモート名]
2
5
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
2
5