Skip to content

Commit e255b92

Browse files
author
tosaken1116
committed
feat: add step 6
1 parent 110f8a5 commit e255b92

File tree

10 files changed

+303
-0
lines changed

10 files changed

+303
-0
lines changed

docs/images/28.png

20.2 KB
Loading

docs/images/29.png

258 KB
Loading

docs/images/30.png

310 KB
Loading

docs/images/31.png

387 KB
Loading

docs/images/32.png

90.2 KB
Loading

docs/images/33.png

20.6 KB
Loading

docs/images/34.png

469 KB
Loading

docs/images/35.png

256 KB
Loading

docs/step5.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,3 +162,5 @@ Assignersを設定しておきましょう
162162
これでプルリクエストの作成とマージが完了しました。
163163

164164
次のステップへ進みましょう。
165+
166+
[次のステップへ](./step6.md)

docs/step6.md

Lines changed: 301 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,301 @@
1+
# issue
2+
3+
githubにはissueという機能があります
4+
5+
issueとは、プロジェクトのタスクやバグを管理するための機能です。issueを使うことで、プロジェクトの進捗状況を把握しやすくなります。
6+
7+
## issueの作成
8+
9+
issueを作成するには、GitHubのWebサイト上で行います。
10+
11+
`issues`をクリックします。
12+
![issue](./images/28.png)
13+
14+
`New issue`ボタンをクリックします。
15+
16+
![new issue](./images/29.png)
17+
18+
![new issue](./images/30.png)
19+
20+
タイトルと本文を入力します。
21+
22+
ここでは例として、テキストファイルの追加を行うissueを作成します。
23+
24+
`Submit new issue`ボタンをクリックします。
25+
26+
27+
issueが作成されました。
28+
29+
![submit new issue](./images/31.png)
30+
31+
自分をアサインしておきましょう。
32+
33+
`Assign yourself`をクリックします。
34+
35+
![assign yourself](./images/32.png)
36+
37+
これでissueの作成が完了しました。
38+
39+
プロジェクト開発は基本的に次のような流れで進められます。
40+
41+
1. issueの作成
42+
2. ブランチの作成
43+
3. コードの変更
44+
4. プルリクエストの作成
45+
5. レビュー
46+
6. マージ
47+
48+
49+
ではこのタスクを実際にやってみましょう
50+
51+
## issueに基づいたタスクを実行する
52+
53+
issueに基づいたタスクを実行するために、issueを参照してブランチを作成し、コードを変更します。
54+
55+
ローカルのターミナルで次のコマンドを実行します。
56+
57+
```bash
58+
git switch main
59+
```
60+
61+
```bash
62+
git switch -c feat/add-text-file-#2
63+
```
64+
65+
実行結果
66+
67+
```
68+
Switched to a new branch 'feat/add-text-file-#2'
69+
```
70+
71+
今回ブランチには`feat/add-text-file-#2`という名前をつけました。
72+
73+
ブランチの命名規則はプロジェクトによって異なりますが今回は次のような規則でつけています
74+
75+
```
76+
[タスクの種類]/[タスクの内容]-#[issue番号]
77+
```
78+
79+
タスクの種類は`feat`(feature)や`fix`(bug fix)などがあります。
80+
81+
タスクの内容はissueのタイトルを参考に簡潔につけましょう
82+
83+
issue番号はissueの番号です。
84+
85+
![branch](./images/33.png)
86+
87+
88+
89+
次に、テキストファイルを作成します。
90+
91+
```bash
92+
echo "Hello, World!" > text.txt
93+
```
94+
95+
```bash
96+
cat text.txt
97+
```
98+
99+
`実行結果`
100+
```
101+
Hello, World!
102+
```
103+
104+
次に、コミットを行います。
105+
106+
```bash
107+
git add text.txt
108+
```
109+
110+
```bash
111+
git commit -m "Add text.txt"
112+
```
113+
114+
`実行結果`
115+
```
116+
[feat/add-text-file-#2 4a41866] Add text.txt
117+
1 file changed, 1 insertion(+)
118+
create mode 100644 text.txt
119+
```
120+
121+
ここで`README.md`をみてみましょう
122+
123+
```bash
124+
cat README.md
125+
```
126+
127+
`実行結果`
128+
```
129+
# hello-world
130+
```
131+
132+
`1. Edit from feature branch`が追加されていません
133+
134+
135+
これはリモートでマージした変更差分がローカルに反映されていないためです
136+
137+
138+
一旦mainブランチに戻ります
139+
140+
```bash
141+
git switch main
142+
```
143+
144+
`実行結果`
145+
```
146+
Switched to branch 'main'
147+
Your branch is behind 'origin/main' by 2 commits, and can be fast-forwarded.
148+
(use "git pull" to update your local branch)
149+
```
150+
151+
`main`ブランチは`origin/main`より2つのコミットが遅れていると表示されています
152+
153+
`origin/main`はリモートリポジトリの`main`ブランチを指しています
154+
155+
`git pull`コマンドを実行することで、リモートリポジトリの変更をローカルリポジトリに取り込むことができます
156+
157+
```bash
158+
git pull
159+
```
160+
161+
`実行結果`
162+
```
163+
Updating 6d45215..da24917
164+
Fast-forward
165+
README.md | 1 +
166+
1 file changed, 1 insertion(+)
167+
```
168+
169+
`README.md`が更新されました
170+
171+
```bash
172+
cat README.md
173+
```
174+
175+
`実行結果`
176+
```
177+
# hello-world
178+
1. Edit from feature branch
179+
```
180+
181+
`1. Edit from feature branch`が追加されています
182+
183+
次に、`feat/add-text-file-#2`ブランチに戻ります
184+
185+
```bash
186+
git switch feat/add-text-file-#2
187+
```
188+
189+
`実行結果`
190+
```
191+
Switched to branch 'feat/add-text-file-#2'
192+
```
193+
194+
`main`ブランチから`feat/add-text-file-#2`ブランチに切り替わりました
195+
196+
ここで`README.md`をみてみましょう
197+
198+
```bash
199+
cat README.md
200+
```
201+
202+
`実行結果`
203+
```
204+
# hello-world
205+
```
206+
207+
おや?`1. Edit from feature branch`が表示されていません
208+
209+
これは`feat/add-text-file-#2`ブランチを作成した時の親ブランチであるmainがリモートリポジトリと同期する前の状態を指しているためです
210+
211+
`main`ブランチに`feat/add-text-file-#2`ブランチの変更を取り込むために、mainブランチにマージします
212+
213+
```bash
214+
git merge main
215+
```
216+
217+
`実行結果`
218+
```
219+
Merge branch 'main' into feat/add-text-file-#2
220+
# Please enter a commit message to explain why this merge is necessary,
221+
# especially if it merges an updated upstream into a topic branch.
222+
#
223+
# Lines starting with '#' will be ignored, and an empty message aborts
224+
# the commit.
225+
~
226+
```
227+
228+
マージコミットメッセージが表示されます
229+
230+
ここではそのまま保存して終了します
231+
232+
`Esc`キーを押して、`:wq`を入力して`Enter`キーを押します
233+
234+
`実行結果`
235+
```
236+
Merge made by the 'ort' strategy.
237+
README.md | 1 +
238+
1 file changed, 1 insertion(+)
239+
```
240+
241+
`README.md`が更新されました
242+
243+
```bash
244+
cat README.md
245+
```
246+
247+
`実行結果`
248+
```
249+
# hello-world
250+
1. Edit from feature branch
251+
```
252+
253+
`1. Edit from feature branch`が表示されています
254+
255+
次に、`feat/add-text-file-#2`ブランチに変更をプッシュします
256+
257+
```bash
258+
git push origin feat/add-text-file-#2
259+
```
260+
261+
`実行結果`
262+
```
263+
Enumerating objects: 7, done.
264+
Counting objects: 100% (7/7), done.
265+
Delta compression using up to 8 threads
266+
Compressing objects: 100% (4/4), done.
267+
Writing objects: 100% (5/5), 580 bytes | 580.00 KiB/s, done.
268+
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
269+
remote:
270+
remote: Create a pull request for 'feat/add-text-file-#2' on GitHub by visiting:
271+
remote: https://github.com/tosaken1116/kcl-git/pull/new/feat/add-text-file-%232
272+
remote:
273+
To github.com:tosaken1116/kcl-git.git
274+
* [new branch] feat/add-text-file-#2 -> feat/add-text-file-#2
275+
```
276+
277+
プッシュが完了しました
278+
279+
次に、プルリクエストを作成します
280+
281+
これはstep5を参考に作ってください
282+
283+
プルリクエストのメッセージの部分に`close #2`と入力してください
284+
285+
![pull request](./images/34.png)
286+
287+
これでissueに基づいたタスクを完了しました
288+
289+
プルリクエストをマージした後issue一覧を見てみましょう
290+
291+
![issue list](./images/35.png)
292+
293+
issueがクローズされていることが確認できます
294+
295+
プルリクエストのメッセージに`close #2`と入力することで、プルリクエストがマージされた時にissueの2番がクローズされるようになります
296+
297+
298+
これで基本的なgit githubの使い方がわかりました
299+
300+
お疲れ様でした
301+

0 commit comments

Comments
 (0)