7
6

More than 3 years have passed since last update.

【Git】新しいブランチの作り方

Last updated at Posted at 2018-10-30

良く忘れるので、メモ書きを兼ねて。
(2019/09/24 git version 2.23.0 リリースに伴い追記)

作業中のファイルがある場合

$ git stash save '自分がわかるメモ'

master ブランチに切り替える

$ git checkout master
$ git switch master (version 2.23.0)

masterブランチを更新する

$ git pull origin master

ブランチを作成するディレクトリに移動する

$ cd ~/...

全ブランチを確認

$ git branch -a

ブランチを作成し、作成したブランチに切り替える

$ git checkout -b ブランチ名
$ git switch -c ブランチ名 (version 2.23.0)

新しいブランチを更新する(-u でデフォルト設定)

$ git push -u origin ブランチ名

今まで使っていたブランチと差分がある場合

$ git cherry-pick コミットID

stashした作業中のファイルを戻す

$ git stash pop

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