LoginSignup
0
0

More than 3 years have passed since last update.

Gitのブランチの操作について

Posted at

ブランチの基本操作について

# ブランチの一覧を見る
git branch -a

# 新規ブランチを作成&切替
git checkout -b {new_branch}

# 新規ブランチを作成&切替(origin/masterを元に)
git checkout -b {new_branch} {origin/master}

# ただの新規ブランチ作成
git branch {new_branch}

# ブランチの切換え
git checkout {new_branch}

# 現在のブランチ確認
git branch --contains

# 特定地点のコミットのブランチを作成する
git checkout {HEAD}

ブランチの削除について

### ローカルブランチの削除
# HEADにマージしたブランチを削除する
git branch --delete {branch_name}

# マージしたかどうかに関わらず削除する
git branch -D {branch_name}

### リモートブランチの削除
# GitHub上で不要なブランチを削除する
# Pull Request > Delete Branch

# ローカルGit上で不要なブランチを削除する
git push --delete origin {branch_name}
0
0
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
0