File tree Expand file tree Collapse file tree
chapter-advanced-features
chapter-branch-operations
chapter-advanced-features
chapter-branch-operations Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -604,9 +604,10 @@ winget install --id GitHub.cli
604604
605605# Ubuntu/Debian
606606curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
607- echo " deb [arch=$( dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] \\
608- https://cli.github.com/packages stable main" | \\
609- sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
607+ ARCH=$( dpkg --print-architecture)
608+ KEYRING=/usr/share/keyrings/githubcli-archive-keyring.gpg
609+ echo " deb [arch=${ARCH} signed-by=${KEYRING} ] https://cli.github.com/packages stable main" | \
610+ sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
610611sudo apt update
611612sudo apt install gh
612613
Original file line number Diff line number Diff line change @@ -188,6 +188,62 @@ Pull Requestには様々な種類があります。新機能追加、バグ修
188188
189189Pull Requestの作成からマージまでの一連の流れを理解し、効率的なチーム開発を実現しましょう。
190190
191+ ### 最小手順(CLI):clone → branch → commit → push → PR
192+ GitHub Desktop ではなくターミナルで作業する場合でも、流れは同じです。ここでは最小手順だけをまとめます。
193+
194+ 前提:
195+ - Git がインストール済み
196+ - リモートは ` origin ` 、統合先は ` <default-branch> ` (例: ` main ` 。プロジェクトにより異なるため要確認)
197+ - PR 作成はブラウザ、または GitHub CLI(` gh ` )を利用(任意)
198+
199+ 1 ) リポジトリを clone して移動します。
200+
201+ ``` bash
202+ git clone https://github.com/< owner> /< repo> .git
203+ cd < repo>
204+ ```
205+
206+ 2 ) 最新の既定ブランチ(ここでは ` <default-branch> ` )を取得し、作業用ブランチを作成します。
207+
208+ ``` bash
209+ git switch < default-branch>
210+ git pull --ff-only
211+ git switch -c feat/< topic>
212+ # 参考: 古い Git の場合
213+ # git checkout -b feat/<topic>
214+ ```
215+
216+ 3 ) 変更をステージし、コミットします(不要なファイルを混ぜない)。
217+
218+ ``` bash
219+ git status
220+ git add < file1> < file2>
221+ # 参考: 変更範囲を確認しながらステージする場合
222+ # git add -p
223+ git commit -m " docs: update ..."
224+ ```
225+
226+ 4 ) リモートへ push します。
227+
228+ ``` bash
229+ git push -u origin feat/< topic>
230+ ```
231+
232+ 5 ) Pull Request を作成します。
233+
234+ - ブラウザ: GitHub 上で ` feat/<topic> ` から ` <default-branch> ` への PR を作成する
235+ - GitHub CLI(任意):
236+
237+ ``` bash
238+ gh pr create --base < default-branch> --head feat/< topic> --title " ..." --body " ..."
239+ ```
240+
241+ ### よくある失敗と回避(最小)
242+ - ` main ` のまま作業してしまう: ` git branch --show-current ` でブランチ名を確認してから編集する
243+ - 意図しないファイルまでコミットする: ` git status ` で差分を確認し、` git add <file> ` または ` git add -p ` を使う
244+ - ` git push ` で upstream エラーになる: 初回は ` git push -u origin <branch> ` を使う
245+ - PR が肥大化する: 目的を 1 つに絞り、無関係な整形やリファクタを混ぜない
246+
191247### 作業用ブランチの削除
192248
193249マージが完了したら、不要になった作業用ブランチを削除できます:
Original file line number Diff line number Diff line change @@ -604,9 +604,10 @@ winget install --id GitHub.cli
604604
605605# Ubuntu/Debian
606606curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
607- echo " deb [arch=$( dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] \\
608- https://cli.github.com/packages stable main" | \\
609- sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
607+ ARCH=$( dpkg --print-architecture)
608+ KEYRING=/usr/share/keyrings/githubcli-archive-keyring.gpg
609+ echo " deb [arch=${ARCH} signed-by=${KEYRING} ] https://cli.github.com/packages stable main" | \
610+ sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
610611sudo apt update
611612sudo apt install gh
612613
Original file line number Diff line number Diff line change @@ -188,6 +188,62 @@ Pull Requestには様々な種類があります。新機能追加、バグ修
188188
189189Pull Requestの作成からマージまでの一連の流れを理解し、効率的なチーム開発を実現しましょう。
190190
191+ ### 最小手順(CLI):clone → branch → commit → push → PR
192+ GitHub Desktop ではなくターミナルで作業する場合でも、流れは同じです。ここでは最小手順だけをまとめます。
193+
194+ 前提:
195+ - Git がインストール済み
196+ - リモートは ` origin ` 、統合先は ` <default-branch> ` (例: ` main ` 。プロジェクトにより異なるため要確認)
197+ - PR 作成はブラウザ、または GitHub CLI(` gh ` )を利用(任意)
198+
199+ 1 ) リポジトリを clone して移動します。
200+
201+ ``` bash
202+ git clone https://github.com/< owner> /< repo> .git
203+ cd < repo>
204+ ```
205+
206+ 2 ) 最新の既定ブランチ(ここでは ` <default-branch> ` )を取得し、作業用ブランチを作成します。
207+
208+ ``` bash
209+ git switch < default-branch>
210+ git pull --ff-only
211+ git switch -c feat/< topic>
212+ # 参考: 古い Git の場合
213+ # git checkout -b feat/<topic>
214+ ```
215+
216+ 3 ) 変更をステージし、コミットします(不要なファイルを混ぜない)。
217+
218+ ``` bash
219+ git status
220+ git add < file1> < file2>
221+ # 参考: 変更範囲を確認しながらステージする場合
222+ # git add -p
223+ git commit -m " docs: update ..."
224+ ```
225+
226+ 4 ) リモートへ push します。
227+
228+ ``` bash
229+ git push -u origin feat/< topic>
230+ ```
231+
232+ 5 ) Pull Request を作成します。
233+
234+ - ブラウザ: GitHub 上で ` feat/<topic> ` から ` <default-branch> ` への PR を作成する
235+ - GitHub CLI(任意):
236+
237+ ``` bash
238+ gh pr create --base < default-branch> --head feat/< topic> --title " ..." --body " ..."
239+ ```
240+
241+ ### よくある失敗と回避(最小)
242+ - ` main ` のまま作業してしまう: ` git branch --show-current ` でブランチ名を確認してから編集する
243+ - 意図しないファイルまでコミットする: ` git status ` で差分を確認し、` git add <file> ` または ` git add -p ` を使う
244+ - ` git push ` で upstream エラーになる: 初回は ` git push -u origin <branch> ` を使う
245+ - PR が肥大化する: 目的を 1 つに絞り、無関係な整形やリファクタを混ぜない
246+
191247### 作業用ブランチの削除
192248
193249マージが完了したら、不要になった作業用ブランチを削除できます:
You can’t perform that action at this time.
0 commit comments