Skip to content

Commit 9bf5feb

Browse files
authored
Initial commit
0 parents  commit 9bf5feb

17 files changed

+671
-0
lines changed

Diff for: .github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"

Diff for: .github/steps/-step.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0

Diff for: .github/steps/0-welcome.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- readme -->

Diff for: .github/steps/1-create-a-pr.md

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!--
2+
<<< Author notes: Step 1 >>>
3+
Choose 3-5 steps for your course.
4+
The first step is always the hardest, so pick something easy!
5+
Link to docs.github.com for further explanations.
6+
Encourage users to open new tabs for steps!
7+
-->
8+
9+
## Step 1: Create a pull request
10+
11+
_Welcome to "Managing Merge Conflicts"! :wave:_
12+
13+
**What is a _merge conflict_?**: A **merge conflict** occurs when changes are made to the same part of the same file on two different branches. You usually find out about conflicts in a pull request so let's start by creating one.
14+
15+
### :keyboard: Activity: Create a pull request
16+
17+
1. Open a new browser tab, and work on the steps in your second tab while you read the instructions in this tab.
18+
1. We made a small change to a file in the repository in the `my-resume` branch.
19+
1. [Create a pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request) setting `my-resume` as the head branch and `main` as the base branch. You can enter `Resolving merge conflicts` for the pull request title and body.
20+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

Diff for: .github/steps/2-resolve-a-merge-conflict.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<!--
2+
<<< Author notes: Step 2 >>>
3+
Start this step by acknowledging the previous step.
4+
Define terms and link to docs.github.com.
5+
-->
6+
7+
## Step 2: Resolve a merge conflict
8+
9+
_Good start! Now let's look deeper at a merge conflict! :mag:_
10+
11+
This can be intimidating, but have no fear, Git is smart when it comes to merging! Git only needs a human to decide how to [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). Sometimes, the best way to resolve a merge conflict is to add content that's from both branches, or even something that isn't on either! This is why Git needs a human to look at the code and make the proper fixes.
12+
13+
### :keyboard: Activity: Resolve a merge conflict
14+
15+
1. Open the pull request that you just created, we created a conflict for you. Have no fear!
16+
1. At the bottom of the page, under "This branch has conflicts that must be resolved", click the **Resolve conflicts** button.
17+
1. Look for the highlighted sections that begins with `<<<<<<< my-resume` and ends with `>>>>>>> main`. These markers are added by Git to show you the content that is in conflict.
18+
1. Remove the changes made on the main branch by deleting all of the content below the `=======` and above `>>>>>>> main`.
19+
1. Next, remove the merge conflict markers by deleting the following lines:
20+
```
21+
<<<<<<< my-resume
22+
=======
23+
>>>>>>> main
24+
```
25+
1. With the merge conflict markers removed, click **Mark as resolved**.
26+
1. Finally, click **Commit merge**.
27+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

Diff for: .github/steps/3-create-your-own-conflict.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!--
2+
<<< Author notes: Step 3 >>>
3+
Start this step by acknowledging the previous step.
4+
Define terms and link to docs.github.com.
5+
-->
6+
7+
## Step 3: Create your own conflict
8+
9+
_Good job! You've solved a merge conflict! :tada:_
10+
11+
Resolving a conflict doesn't automatically merge the pull request in GitHub. Instead, it stores the resolution of the conflict in a merge commit and allows you and your team to keep working. To resolve a conflict, GitHub performs what is known as a _reverse merge_. This means that the changes from the `main` branch were merged into your `my-resume` branch. With a reverse merge, only the `my-resume` branch is updated. This allows you to test the resolved changes on your branch before you merge it into `main`.
12+
13+
Now, let's get a little evil. (It's for educational purposes!)
14+
15+
### :keyboard: Activity: Create your own conflict
16+
17+
We went ahead and added a new file called `references.md` and pushed that change to `main`, without updating your `my-resume` branch.
18+
19+
1. Browse to the `my-resume` branch.
20+
1. Click the `Add file` dropdown menu and then on `Create new file`.
21+
1. Create a file named `references.md`.
22+
1. Enter some text that conflicts with what we added for `references.md` in the `main` branch.
23+
1. Scroll to the bottom of the page and enter a commit message for your change.
24+
1. Click the **Commit new file** button, making sure the "Commit directly to the `my-resume` branch" option is selected.
25+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

Diff for: .github/steps/4-merge-your-pull-request.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!--
2+
<<< Author notes: Step 4 >>>
3+
Start this step by acknowledging the previous step.
4+
Define terms and link to docs.github.com.
5+
-->
6+
7+
## Step 4: Merge your pull request
8+
9+
_Almost there! :heart:_
10+
11+
You can now [merge](https://docs.github.com/en/get-started/quickstart/github-glossary#merge) your pull request!
12+
13+
### :keyboard: Activity: Merge your pull request
14+
15+
1. First, resolve any remaining conflicts in your pull request.
16+
> Look back at step one if you need help.
17+
1. Click **Merge pull request**.
18+
1. Delete the branch `my-resume` (optional).
19+
1. Wait about 20 seconds then refresh this page (the one you're following instructions from). [GitHub Actions](https://docs.github.com/en/actions) will automatically update to the next step.

Diff for: .github/steps/X-finish.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!--
2+
<<< Author notes: Finish >>>
3+
Review what we learned, ask for feedback, provide next steps.
4+
-->
5+
6+
## Finish
7+
8+
_Congratulations friend, you've completed this course!_
9+
10+
<img src=https://octodex.github.com/images/benevocats.jpg alt=celebrate width=300 align=right>
11+
12+
Here's a recap of all the tasks you've accomplished in your repository:
13+
14+
- You learned why merge conflicts happen.
15+
- You resolved a simple merge conflict.
16+
- You created a merge conflict, and resolved it!
17+
18+
### What's next?
19+
20+
- Make your own Markdown resume site with GitHub Pages! Learn how in our [GitHub Pages](https://github.com/skills/github-pages) course.
21+
- We'd love to hear what you thought of this course [in our discussion board](https://github.com/orgs/skills/discussions/categories/resolve-merge-conflicts).
22+
- [Take another GitHub Skills course](https://github.com/skills).
23+
- [Read the GitHub Getting Started docs](https://docs.github.com/en/get-started).
24+
- To find projects to contribute to, check out [GitHub Explore](https://github.com/explore).

Diff for: .github/workflows/0-welcome.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Step 0, Welcome
2+
3+
# This step triggers after the learner creates a new repository from the template.
4+
# This workflow updates from step 0 to step 1.
5+
6+
# This will run every time we create push a commit to `main`.
7+
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
8+
on:
9+
workflow_dispatch:
10+
push:
11+
branches:
12+
- main
13+
14+
# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
15+
permissions:
16+
# Need `contents: read` to checkout the repository.
17+
# Need `contents: write` to update the step metadata.
18+
contents: write
19+
20+
jobs:
21+
# Get the current step to only run the main job when the learner is on the same step.
22+
get_current_step:
23+
name: Check current step number
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
- id: get_step
29+
run: |
30+
echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT
31+
outputs:
32+
current_step: ${{ steps.get_step.outputs.current_step }}
33+
34+
on_start:
35+
name: On start
36+
needs: get_current_step
37+
38+
# We will only run this action when:
39+
# 1. This repository isn't the template repository.
40+
# 2. The step is currently 0.
41+
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
42+
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
43+
if: >-
44+
${{ !github.event.repository.is_template
45+
&& needs.get_current_step.outputs.current_step == 0 }}
46+
47+
# We'll run Ubuntu for performance instead of Mac or Windows.
48+
runs-on: ubuntu-latest
49+
50+
steps:
51+
# We'll need to check out the repository so that we can edit the README.
52+
- name: Checkout
53+
uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 0 # Let's get all the branches.
56+
57+
- name: Prepare a branch
58+
run: |
59+
echo "Make sure we are on step 0"
60+
if [ "$(cat .github/steps/-step.txt)" != 0 ]
61+
then
62+
echo "Current step is not 0"
63+
exit 0
64+
fi
65+
66+
echo "Make a branch"
67+
BRANCH=my-resume
68+
git checkout -b $BRANCH
69+
70+
echo "Update resume.md"
71+
sed -i.bak 's/Experience/Job History/' resume.md
72+
73+
echo "Make a commit"
74+
git config user.name github-actions[bot]
75+
git config user.email github-actions[bot]@users.noreply.github.com
76+
git add resume.md
77+
git commit --message="Update resume.md in my-resume"
78+
79+
echo "Push"
80+
git push --set-upstream origin $BRANCH
81+
env:
82+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
84+
# In README.md, switch step 0 for step 1.
85+
- name: Update to step 1
86+
uses: skills/action-update-step@v2
87+
with:
88+
token: ${{ secrets.GITHUB_TOKEN }}
89+
from_step: 0
90+
to_step: 1
91+
branch_name: my-resume

Diff for: .github/workflows/1-create-a-pr.yml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Step 1, Create a pull request
2+
3+
# This step triggers after the learner creates a pull request for the my-resume branch
4+
# This workflow updates from step 1 to step 2.
5+
6+
# This will run every time we open a pull request.
7+
# Reference: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows
8+
on:
9+
workflow_dispatch:
10+
pull_request:
11+
types: [opened]
12+
13+
# Reference: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
14+
permissions:
15+
# Need `contents: read` to checkout the repository.
16+
# Need `contents: write` to update the step metadata.
17+
contents: write
18+
19+
jobs:
20+
# Get the current step to only run the main job when the learner is on the same step.
21+
get_current_step:
22+
name: Check current step number
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
- id: get_step
28+
run: |
29+
echo "current_step=$(cat ./.github/steps/-step.txt)" >> $GITHUB_OUTPUT
30+
outputs:
31+
current_step: ${{ steps.get_step.outputs.current_step }}
32+
33+
on_create_pr:
34+
name: On create PR
35+
needs: get_current_step
36+
37+
# We will only run this action when:
38+
# 1. This repository isn't the template repository.
39+
# 2. The step is currently 1.
40+
# Reference: https://docs.github.com/en/actions/learn-github-actions/contexts
41+
# Reference: https://docs.github.com/en/actions/learn-github-actions/expressions
42+
if: >-
43+
${{ !github.event.repository.is_template
44+
&& needs.get_current_step.outputs.current_step == 1 }}
45+
46+
# We'll run Ubuntu for performance instead of Mac or Windows.
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
# We'll need to check out the repository so that we can edit the README.
51+
- name: Checkout
52+
uses: actions/checkout@v4
53+
with:
54+
fetch-depth: 0 # Let's get all the branches.
55+
56+
- name: Prepare a merge conflict
57+
run: |
58+
echo "Make sure we are on step 1"
59+
if [ "$(cat .github/steps/-step.txt)" != 1 ]
60+
then
61+
echo "Current step is not 1"
62+
exit 0
63+
fi
64+
65+
echo "Manually update step in my-resume to match step in main branch"
66+
git checkout my-resume
67+
git config user.name github-actions[bot]
68+
git config user.email github-actions[bot]@users.noreply.github.com
69+
sed -i.bak 's/1/2/' .github/steps/-step.txt
70+
git add .github/steps/-step.txt
71+
git commit --message="Update step in my-resume"
72+
echo "Push"
73+
git push origin my-resume
74+
75+
echo "Create a merge conflict in main"
76+
git checkout main
77+
sed -i.bak 's/Experience/Jobs/' resume.md
78+
git add resume.md
79+
git commit --message="Update resume.md in main"
80+
81+
echo "Push"
82+
git push origin main
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
86+
# In README.md, switch step 1 for step 2.
87+
- name: Update to step 2
88+
uses: skills/action-update-step@v2
89+
with:
90+
token: ${{ secrets.GITHUB_TOKEN }}
91+
from_step: 1
92+
to_step: 2
93+
branch_name: my-resume

0 commit comments

Comments
 (0)