LoginSignup
1
3

More than 5 years have passed since last update.

開発に最低限必要なgitの使い方説明します。

設定編

gitコマンド出力に色をつける

$ git config --global color.ui true

git pushコマンドを実行した際、現在のブランチと同じ名前のリモートブランチを更新する

$ git config --global push.default current

ブランチ編

現在のブランチを確認する

$ git branch

[~/alq]$ git branch                                                                                                                                                                                                                                                   [master]
  feature/user_create
  feature/user_init
  feature/user_login
  feature/user_logout
  fix/logout
* master
トッピクブランチを作成して、ブランチを変更する。

$ git checkout -b feature/new_name

ブランチが切り替わっていることを確認

$ git branch

* feature/new_name
  feature/user_create
  feature/user_init
  feature/user_login
  feature/user_logout
  fix/logout
  master

コミット編

変更したファイルをステージングにあげる

$ git add file_name

あんまりよくないですが

$ git add .

のほうが楽なので、理解できるまではこちらを使いましょう。

もし余分な変更がコミットに入っても、プルリクエスト時にレビューするので大丈夫だと思います。

ステージングの上がっているファイル群を一つのバージョンとしてまとめる。(コミット)

$ git commit

viが開き、コミットのメッセージを書くことができます(必ずしないといけない)

viがなれない場合は

$ git commit -m "コミットメッセージ"
を使うと良いと思います。

ローカルの変更をリモート(github)に反映させる。

$ git push

本当は

$ git push origin feature/new_name

としたほうがよいのですが、

上の設定編でデフォルと現在のブランチと同じ名前のリモートブランチを

変更するようにしましたので

$ git push

で良いと思います。   

pushしたならば、githubで確認すると良いと思います。  

1
3
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
3