Skip to content

Commit e74f0bc

Browse files
authored
feat: refresh exercise and update to latest guidelines (#1)
1 parent 998c83a commit e74f0bc

18 files changed

+357
-350
lines changed

.github/steps/1-create-a-pr.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

.github/steps/1-step.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Step 1: Learn about merge conflicts
2+
3+
### What is a merge conflict?
4+
5+
A **merge conflict** occurs when changes are made to the same part of the same file on two different branches.
6+
7+
```mermaid
8+
gitGraph
9+
checkout main
10+
commit id: "Initial"
11+
commit id: "Add resume.md"
12+
13+
branch my-resume
14+
checkout my-resume
15+
commit id: "Update skills"
16+
17+
checkout main
18+
commit id: "Also update skills"
19+
20+
checkout my-resume
21+
commit id: "Other changes"
22+
23+
checkout main
24+
merge my-resume id: "Conflict!"
25+
```
26+
27+
**What's happening here:**
28+
29+
1. We start with a repository and add a `resume.md` file.
30+
2. We create a new branch called `my-resume` and update the skills area.
31+
3. At the same time, someone else also updates the skills area on the `main` branch.
32+
4. We add other unrelated changes to the `my-resume` branch.
33+
5. When we try to merge `my-resume` into `main`, we get a **conflict!** Both branches modified the same part of `resume.md`.
34+
35+
### ⌨️ Activity: Create a pull request
36+
37+
To quickly practice, we already created the above scenario for you by making a new branch `my-resume` then modifying `resume.md` on both branches, which will will cause a conflict. Let's practice with it!
38+
39+
1. Open this repo in a new browser tab, and work on the steps in your second tab while you read the instructions in this tab.
40+
41+
1. In the top navigation, select the **Pull requests** tab.
42+
43+
1. Click the **New pull request** button and use the following settings:
44+
45+
- Base: `main`
46+
- Compare: `my-resume`
47+
- Title: `Resolve a merge conflict`
48+
49+
1. With the new pull request opened, Mona will share the next steps.

.github/steps/2-resolve-a-merge-conflict.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/steps/2-step.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
## Step 2: Resolve a merge conflict
2+
3+
Managing conflicts can be intimidating, but have no fear, Git is smart with merging! Git only needs a human to decide when the situation is very unclear.
4+
5+
You typically have 3 options for managing a conflict:
6+
7+
1. Accept the version from the base branch.
8+
1. Accept the version from the compare branch.
9+
1. Manually combined the changes from both branches.
10+
11+
> [!TIP]
12+
> You can learn more about managing conflicts on the [GitHub Docs: resolve the conflict](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/resolving-a-merge-conflict-using-the-command-line) page.
13+
14+
### When should I resolve a conflict?
15+
16+
Conflicts can be resolved as soon as they are noticed. Resolving a conflict doesn't automatically merge the pull request in GitHub. Instead, it stores the conflict's resolution as a **reverse merge** commit, allowing you to keep working on your branch as normal.
17+
18+
This means that some changes from the `base` branch (`main`) are merged into the `compare` branch (`my-resume`). Only the `compare` branch is updated, which allows you to test the resolved changes before merging.
19+
20+
```mermaid
21+
gitGraph
22+
checkout main
23+
commit id: "Initial"
24+
commit id: "Add resume.md"
25+
26+
branch my-resume
27+
checkout my-resume
28+
commit id: "Update skills"
29+
30+
checkout main
31+
commit id: "Also update skills"
32+
33+
checkout my-resume
34+
commit id: "Other changes"
35+
36+
checkout my-resume
37+
merge main id: "Resolve conflict"
38+
commit id: "Continue work"
39+
40+
checkout main
41+
merge my-resume id: "Success!"
42+
43+
```
44+
45+
### ⌨️ Activity: Resolve a merge conflict
46+
47+
1. If needed, open the recently created pull request.
48+
49+
1. Scroll to the bottom of the page. Near the merge button, notice a message indicating there are conflicts to be resolved.
50+
51+
1. Press the **Resolve conflicts** button to open a special text editor for handling merge conflicts.
52+
53+
1. Look for a highlighted section similar to the below, which shows both versions of the conflict.
54+
55+
```txt
56+
<<<<<<< my-resume
57+
- Contributed to open source projects
58+
=======
59+
- Built internal tools
60+
>>>>>>> main
61+
```
62+
63+
1. After some inspection, we decide to keep the version from the compare branch. Remove the base branch version by deleting then content between `=======` and `>>>>>>> main`.
64+
65+
```txt
66+
<<<<<<< my-resume
67+
- Contributed to open source projects
68+
=======
69+
>>>>>>> main
70+
```
71+
72+
1. With our manual changes finished, let's remove the merge conflict markers. Only the content from the compare branch will remain.
73+
74+
```txt
75+
- Contributed to open source projects
76+
```
77+
78+
1. In the top right, click the **Mark as resolved** button and choose **Commit merge**.
79+
80+
1. With the conflict resolved, Mona will share the next steps.

.github/steps/3-create-your-own-conflict.md

Lines changed: 0 additions & 21 deletions
This file was deleted.

.github/steps/3-step.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## Step 3: Merge your pull request
2+
3+
Nice work! All that remains is to merge!
4+
Yep, that's it! Merge conflicts can be easy! 🥰
5+
6+
### ⌨️ Activity: Merge your pull request
7+
8+
1. Click the **Merge pull request** button.
9+
10+
1. (optional) Delete the branch `my-resume`.
11+
12+
1. With the pull request merged, Mona will share a final review then update the readme to share your success. Nice work! 😎

.github/steps/4-merge-your-pull-request.md

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/steps/X-finish.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/steps/x-review.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## Review
2+
3+
<img src=https://octodex.github.com/images/benevocats.jpg alt=celebrate width=300 align=right>
4+
5+
Congratulations! You've successfully completed the **Resolve Merge Conflicts** exercise. 🎉
6+
7+
You've learned essential skills for collaborative development on GitHub:
8+
9+
- **Understanding merge conflicts**: You now know why conflicts occur when multiple people edit the same file
10+
- **Identifying conflicts**: You can recognize when GitHub detects merge conflicts in pull requests
11+
- **Resolving conflicts**: You've practiced using GitHub's web editor to manually resolve conflicts by choosing which changes to keep
12+
- **Merging successfully**: You completed the workflow by merging your pull request after resolving conflicts
13+
14+
### What's next?
15+
16+
Check out other [GitHub Skills exercises](https://learn.github.com/skills).
17+
18+
- [GitHub Pages](https://github.com/skills-dev/github-pages) - Publish your own static website for free.
19+
- [Communicate using Markdown](https://github.com/skills-dev/communicate-using-markdown) - Improve your documentation skills
20+
- [Getting Started with GitHub Copilot](https://github.com/skills/getting-started-with-github-copilot) - Learn, build, debug and ship faster with an AI pair programmer.

.github/workflows/0-start-exercise.yml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ permissions:
1111
issues: write
1212

1313
env:
14-
STEP_1_FILE: ".github/steps/1-create-a-pr.md"
14+
STEP_1_FILE: ".github/steps/1-step.md"
1515

1616
jobs:
1717
start_exercise:
1818
if: |
1919
!github.event.repository.is_template
2020
name: Start Exercise
21-
uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.5.0
21+
uses: skills/exercise-toolkit/.github/workflows/start-exercise.yml@v0.7.0
2222
with:
2323
exercise-title: "Resolve Merge Conflicts"
2424
intro-message: "Let's learn how to resolve merge conflicts when collaborating on GitHub."
@@ -27,8 +27,6 @@ jobs:
2727
name: Prepare merge conflict
2828
runs-on: ubuntu-latest
2929
needs: [start_exercise]
30-
env:
31-
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
3230

3331
steps:
3432
- name: Checkout
@@ -43,24 +41,25 @@ jobs:
4341
git config user.email github-actions[bot]@users.noreply.github.com
4442
echo "- Contributed to open source projects" >> resume.md
4543
git add resume.md
46-
git commit -m "Add open source contribution"
44+
git commit -m "Add open source experience"
4745
git push origin my-resume
4846
4947
git checkout main
5048
git pull --rebase origin main
51-
echo "- Built internal tools at Acme Corp" >> resume.md
49+
echo "- Built internal tools" >> resume.md
5250
git add resume.md
53-
git commit -m "Add Acme Corp experience"
51+
git commit -m "Add internal experience"
5452
git push origin main
5553
env:
5654
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
55+
5856
post_next_step_content:
5957
name: Post next step content
6058
runs-on: ubuntu-latest
61-
needs: [start_exercise, prepare_merge_conflict]
59+
needs: [start_exercise]
6260
env:
63-
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
61+
ISSUE_NUMBER: ${{ needs.start_exercise.outputs.issue-number }}
62+
ISSUE_REPOSITORY: ${{ github.repository }}
6463

6564
steps:
6665
- name: Checkout
@@ -71,24 +70,24 @@ jobs:
7170
with:
7271
repository: skills/exercise-toolkit
7372
path: exercise-toolkit
74-
ref: v0.5.0
73+
ref: v0.7.0
7574

7675
- name: Create comment - add step content
77-
run: |
78-
gh issue comment "$ISSUE_URL" \
79-
--body-file "$STEP_1_FILE"
80-
env:
81-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
uses: GrantBirki/[email protected]
77+
with:
78+
repository: ${{ env.ISSUE_REPOSITORY }}
79+
issue-number: ${{ env.ISSUE_NUMBER }}
80+
file: ${{ env.STEP_1_FILE }}
8281

8382
- name: Create comment - watching for progress
84-
run: |
85-
gh issue comment "$ISSUE_URL" \
86-
--body-file "exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md"
87-
env:
88-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
uses: GrantBirki/[email protected]
84+
with:
85+
repository: ${{ env.ISSUE_REPOSITORY }}
86+
issue-number: ${{ env.ISSUE_NUMBER }}
87+
file: exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
8988

9089
- name: Enable next step workflow
9190
run: |
9291
gh workflow enable "Step 1"
9392
env:
94-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)