LoginSignup
2
1

GitHub ブランチ関係のコマンド まとめ(作成〜プッシュ)

Last updated at Posted at 2024-05-17

はじめに

よく使うブランチ関係のコマンドをアウトプットしています。
統合ブランチをdevelop、作業ブランチをfeatureとしています。

コマンドメモ

・ブランチの確認
*がついている場所が今いるブランチ

$ git branch
*main 

・ブランチの作成・移動
developブランチを作成して、移動

$ git checkout -b develop
$ git branch
main
*develop

・ブランチの移動

$ cd アプリケーション
$ git checkout develop

・リモートの(統合ブランチの)最新版をローカルに反映させる

$ git pull origin develop

・統合ブランチであるdevelopブランチから作業ブランチを作成する

$ git checkout develop
$ git checkout -b 作業ブランチ名

・作業ブランチから内容をコミットする

$ git status
$ git add -A
$ git commit -m "コミット名"

・リモートリポジトリにpushする

$ git push origin 作業ブランチ名

ブランチ名変更

ブランチ名の変更コマンドもメモしときます!

$ git branch -m 古いブランチ名 新しいブランチ名

// 今いるブランチの名前を変更する場合

$ git branch -m 新しいブランチ名

GitHubのコミットにIssuesを関連付けてcloseにする

closeでマージしたときにIssuesをcloseさせる
#数字 で作成済みのIssuesに関連付ける

$ git commit -m "close #68"

あとはマージするだけでIssuesがcloseされる!

コミットメッセージを変えたい!コミットを上書きしたい!

Issues連携するの忘れてた!
コミットを上書きしたい!ってときに便利なコマンドです↓

$ git commit --amend -m "新しいコミットメッセージ"

空コミットの仕方

$ git commit --allow-empty -m "空コミットメッセージ"
$ git push origin ブランチ名

ログの確認方法

--onelineで見やすく絞り込む
qで閉じる

git log --oneline

さいごに

都度追加してます!

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