0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

「初心者向け」GitHubでのブランチについて

Posted at

はじめに

マックPCを利用し、SSH接続をしている前提です。
SSH接続について知りたい方はこちらの記事がおすすめ

ブランチの作成

まず、cdを使いpushしたいファイルまで移動しましょう。名前は任意で変えてください。
移動できたら以下のコードを実行していきます。

$git branch develop

こうすることで、developブランチを作成することができます。
実際にgit branchで確認してみましょう

$git branch
 develop
*master  ←デフォルトで作成されているブランチ、mainになってる人もいるかも

という形になっていたら成功です。
(*は今いるブランチを表しています.)

ブランチの移動

今はmasterブランチにいるので、ここからdevelopブランチに移動しましょう。

$git checkout develop

また、実際にgit branchで確認してみましょう

 $git branch
*develop
 master

このように、developの左側に*がついていたら移動成功です。

1発でブランチを作って移動する方法

ここまで2回コマンドを打ってブランチの作成と移動を行なってきましたが、1発でこれらを完了することもできます。

 $git choecout -b develop2

これでdevelop2というブランチを作成し移動することができます。
また、実際にgit branchで確認してみましょう

 $git branch
  develop
 *develop2
  master

このようにdevelop2の左側に*がついていたら移動成功です。

ブランチの削除

間違って作成してしまったブランチを削除しましょう。
今回はdevelop2ブランチを削除していきます。

$git branch -d develop2

また、git branchで確認してみてください。削除されていたら成功です。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?