Collaborate with a change history
English translation
Create your own copy to run, edit, and record results.
- Name: ⟦Enter here⟧
- Student ID: ⟦Enter here⟧
Exercise objective
Record edits with Commits, review changes in a PR, and check how Merge applies them to main. Use your own Repository for this exercise; Forks and PRs on a peer's Repository are optional.
For an external contributor's proposed changes and why each step is needed, see the explanation in the learning material.
Exercise sequence and rationale: First, use a temporary Repository in Colab to examine the relationship between file edits, Commits, and Branches without logging in or configuring permissions. Then create a separate repository on the GitHub website to practice PR review and Merge. You will understand Git change history and then use GitHub collaboration features; you will not upload the repository created in Colab.
- Run Code Cells: ▶ or
Shift+Enter, in order from the top. - Edit a Text Cell: double-click → write
your response→Shift+Enter. - Response cell: enter your own code.
- After changing values: rerun that cell and the relevant cells below it.
1. Practice Git in your own workspace
After practicing Commits and Branches in a temporary Colab folder, follow the steps below for PRs and Merges on GitHub.
A. Baseline example · Read and run first
import tempfile, pathlib, subprocess
repo=pathlib.Path(tempfile.mkdtemp(prefix='course-git-'))
def git(*args):
return subprocess.check_output(['git','-C',str(repo),*args],text=True,stderr=subprocess.STDOUT)
git('init','-b','main');git('config','user.name','Student Example');git('config','user.email','example@example.invalid')
(repo/'README.md').write_text('# Practice\nBaseline\n')
git('add','README.md');git('commit','-m','Add baseline')
git('switch','-c','practice-change')
(repo/'README.md').write_text('# Practice\nBaseline\nMy change\n')
print(git('diff'));git('add','README.md');git('commit','-m','Describe one change')
print(git('log','--oneline','--all','--graph'))
B. Hands-on activities
A Branch is a workflow recording changes separately. Here, create practice from the default Branch main and edit it. A Pull Request (PR) requests review before merging these changes into main; Merge actually combines the reviewed changes. Creating a PR alone does not change main.
Practice change history in Colab: Edit one sentence in the local example and repeat
git diff → add → commit → logyourself.Create a practice Repository on GitHub: Create a personal practice Repository with a README.
Edit and Commit on a Branch: Create a new Branch
practice, add what you learned this week to the README, and Commit.Review the PR and Merge: Open the Pull Request for
practice → main, review the changes under Files changed, and Merge.Explain the changes: Explain the roles of the two Branches and the differences before and after Merge to a teaching assistant or peer.
Record results: Record the Repository URL, Commit history, PR changes, and completed Merge screen in the Notebook.
At each stage, check which Branch records the changes. Compare main's content when the PR is opened and when it is Merged.
# ✍ Write your own: add your code below this cell.
# You may add Code Cells if the code gets long.
C. Your record · Double-click this Text Cell to edit
- Conditions checked or changed: ⟦Enter your response⟧
- Prediction before execution: ⟦Enter your response⟧
- What I checked in Commits, PRs, and Merges: ⟦Enter your response⟧
- Difference from prediction and explanation: ⟦Enter your response⟧
Summarize change history
Review the file edits, Commits, PRs, and Merges you completed and summarize the following. You do not need to create three additional Repositories or PRs.
| Step | What to check | My notes |
|---|---|---|
| Edit and Commit | What did you change, and what message did you use to record it? | ⟦Enter your response⟧ |
| PR | What are the source Branch of the changes and the target Branch for merging? | ⟦Enter your response⟧ |
| Merge | Where can you see the content applied to main and the Commit history? | ⟦Enter your response⟧ |
# ✍ Code for repeated experiments
Optional exercise · Fork and Pull Request
Proceed when a peer has a public Repository for practicing together.
- Fork your peer's Repository and create a Branch in your Fork.
- Edit one explanatory sentence in
README.md, then Commit and Push. - Open a Pull Request to the original Repository and explain the reason for the change in one sentence.
- In a Text Cell in the notebook, record the Pull Request URL and the sentence you changed. Explain why you can propose changes without permission to Push directly to the original Repository.
Save and submit
Save the Notebook to your Drive.
Include the edited content, Commit, Pull Request, and Merge history, and notes explaining what you did at each step. Submit through KLAS; check the semester schedule and latest announcements for deadlines.
Capture your GitHub collaboration results in screenshots showing changes in the repository, Branches, and PRs, and the Merge history. Exclude credentials. The Notebook is for practice and notes.