Open in VS Code: From your cloned
s26-06643repository, run in the terminal:code sse/08-github-collaboration/08-github-collaboration.ipynb
Module 08: GitHub Collaboration#
Work with others (and AI) on GitHub.
Learning Objectives#
Push and pull from remote repositories
Create and review pull requests
Use AI for PR descriptions and reviews
Manage issues and projects
Remote Repositories#
# Clone a repo
git clone https://github.com/user/repo.git
# Add remote to existing repo
git remote add origin https://github.com/user/repo.git
# Push changes
git push origin main
# Pull changes
git pull origin main
# Fetch without merging
git fetch origin
Context Engineering Reminder (from Module 00)
Before starting this exercise, think about what context the agent needs. For collaboration, that means:
Before writing a PR description, run
git diffandgit log --onelineso the agent can see what actually changedBefore resolving a merge conflict, show the agent both versions of the conflicting code
Load the project’s CLAUDE.md or contributing guidelines so the agent follows team conventions
Load the context first, then ask for the action.
Exercise 1: Push to GitHub (10 min)#
Practice the push/pull workflow with a real GitHub repository.
Create a new repo on GitHub. Either use the web interface (github.com → New Repository) or run:
gh repo create my-test-repo --public --clone
If using an existing local repo (e.g., your
git-practicerepo), add the remote:git remote add origin https://github.com/<your-username>/my-test-repo.git
Push your code:
git push -u origin main
Visit your GitHub repo page — your code is now online! Verify the files are there.
Make an edit on GitHub’s web interface: Click on
README.md(or any file), click the pencil icon, add a line, and commit directly on GitHub.Pull the change locally:
git pull origin main
Verify:
git log --oneline
You should see the commit you made on GitHub.
Expected outcome: You have a repo that exists both locally and on GitHub, and you’ve practiced the push/pull sync cycle.
Pull Requests#
Workflow#
Create feature branch
Make changes, commit
Push branch to GitHub
Open Pull Request
Review and discuss
Merge when approved
# Create and push branch
git checkout -b feature/add-search
# ... make changes ...
git add .
git commit -m "feat: Add search functionality"
git push -u origin feature/add-search
Exercise 2: Create a Pull Request (10 min)#
Practice the full PR workflow on your GitHub repository.
Create a feature branch locally:
git checkout -b add-feature
Make a change. Add a new file or modify existing code. For example, create
hello.py:def greet(name): return f"Hello, {name}!"
Commit and push the branch:
git add . git commit -m "feat: add greeting function" git push -u origin add-feature
Go to GitHub and you should see a banner suggesting you create a Pull Request. Click it (or go to the Pull Requests tab → New Pull Request).
Fill in a title and description, then create the PR.
Explore the PR page. Answer these questions:
What tabs are available (Conversation, Commits, Files changed)?
How many commits are in this PR?
Can you see the diff of your changes?
Don’t merge yet — we’ll come back to this PR.
Expected outcome: You have an open PR on GitHub and understand what information the PR page shows.
AI-Generated PR Descriptions#
> Write a PR description for these changes:
[shows git diff]
Include:
- Summary of changes
- Why the changes were made
- How to test
- Any breaking changes
AI generates:
## Summary
Add search functionality to the OpenAlex client.
## Changes
- Add `search_works()` function
- Add pagination support
- Update README with examples
## Testing
- Run `pytest tests/test_search.py`
- Manual test: `python -c "from mypackage import search; print(search('AI'))"`
## Breaking Changes
None
Exercise 3: AI PR Description (5 min)#
Use AI to draft a professional PR description.
Ask your AI agent (Claude, ChatGPT, or your CLI agent):
“I’m creating a PR that adds a
calculate_h_indexfunction tometrics.pywith 5 pytest tests. Write a PR description.”Read the AI-generated description. Does it include:
A summary of what changed?
Why the change was made?
How to test it?
Any breaking changes?
Compare with what you’d write manually. Consider:
Is the AI version better or worse?
What context is the AI missing? (e.g., it doesn’t know your project’s conventions, related issues, or the motivation behind the feature)
Would you use it as-is, or as a starting draft?
Expected outcome: You see how AI can accelerate PR descriptions, but also understand its limitations — it can’t know why you made the change or what issues it relates to.
AI Code Review#
Use AI to review PRs:
> Review this diff for:
- Bugs or errors
- Security issues
- Performance concerns
- Style improvements
- Missing tests
[paste diff]
Also works on others’ PRs - AI helps you give better feedback.
Exercise 4: Review a Diff (10 min)#
Practice code review — a critical collaboration skill.
Look at this code change and write review comments:
# Before:
def search(query):
r = requests.get(f"https://api.openalex.org/works?search={query}")
return r.json()
# After:
def search(query, limit=10):
url = f"https://api.openalex.org/works?search={query}&per_page={limit}"
r = requests.get(url)
r.raise_for_status()
data = r.json()
return data['results']
Write your own review (2-3 minutes). Consider:
What improved in the new version?
What’s still missing? (Think about: input validation, docstring, type hints, error handling for JSON parsing, URL encoding of the query string)
Now ask your AI agent to review the same diff:
“Review this code change for bugs, security issues, performance, style, and missing tests: [paste the before/after code]”
Compare your review with the AI’s review:
Did the AI catch things you missed?
Did you catch things the AI missed?
Whose review would be more helpful to the author?
Expected outcome: You’ve practiced reading diffs critically and seen how AI can augment (but not replace) human code review.
GitHub CLI#
# Install: https://cli.github.com
# Create PR from command line
gh pr create --title "Add search" --body "Description here"
# List PRs
gh pr list
# View PR
gh pr view 123
# Merge PR
gh pr merge 123
Issues#
Track bugs and features:
# Create issue
gh issue create --title "Bug: Search fails" --body "Description"
# List issues
gh issue list
# Close with commit
git commit -m "fix: Search error (closes #123)"
Exercise: Contribute to Partner’s Repo#
Fork a classmate’s package
Add a feature or fix a bug
Create a PR with AI-generated description
Review a PR on your repo
Merge when ready
Summary#
Action |
Command |
|---|---|
Push |
|
Pull |
|
Create PR |
|
Review |
Use AI + your judgment |
Tips and Tricks#
Prompt: “Write a PR description for these changes: [paste diff or summary]”: AI writes good PR descriptions when you give it the diff.
Keep PRs small and focused: One feature or fix per PR — easier to review, easier to revert, faster to merge.
Prompt: “Review this diff and suggest improvements: [paste diff]”: AI can be your first reviewer before a human looks at it.
Use issue templates: Ask the agent: “Create a GitHub issue template for bug reports” — it generates good markdown templates.
Write descriptive branch names:
fix/null-pointer-in-parseris better thanfix-bug— the agent can help: “Suggest a branch name for [description].”Prompt: “Resolve this merge conflict: [paste conflicting sections]”: AI is good at merging conflicting code when you show it both versions.
Respond to review comments with code, not words: When a reviewer requests a change, fix it and push — do not argue in comments.
Use
ghCLI for GitHub operations:gh pr create,gh issue list— faster than the browser for quick tasks.
Foundational Concepts to Commit to Memory#
Remote = a copy of your repo hosted elsewhere (usually GitHub);
originis the default name for itPush/Pull = push sends your local commits to the remote; pull fetches remote commits and merges them into your local branch
Fork = your personal copy of someone else’s repo on GitHub, where you can make changes without affecting the original
Pull Request (PR) = a proposal to merge your branch into another branch; it is where code review, discussion, and CI checks happen before merging
Code review = reading someone else’s changes and providing feedback; one of the highest-value collaboration activities in software engineering
ghCLI = GitHub’s command-line tool;gh pr create,gh pr list,gh issue createare the commands you will use mostClosing keywords = writing
closes #123orfixes #123in a commit message automatically closes the referenced issue when mergedAI-assisted review = AI can catch mechanical issues (style, missing tests, common bugs) but cannot evaluate design decisions, motivation, or project context — that requires a human
Knowing vs. Doing: Reflection#
Collaboration is where the gap between knowing and doing becomes most visible. You can read every page of GitHub’s documentation on pull requests, branch protection rules, and code review best practices — but none of it sticks until you have actually resolved a merge conflict at 11pm, or received a code review that made you rethink your entire approach. The experience of collaboration is what builds your instincts for when to branch, when to ask for review, and when to just merge and move on.
At the same time, AI can dramatically accelerate the mechanical parts of collaboration. It can draft PR descriptions, suggest review comments, and even help you understand a teammate’s diff faster than you could parse it alone. This frees you to focus on the parts that require human judgment: Does this change make architectural sense? Is the motivation clear? Will this confuse someone six months from now? The more you understand about collaboration workflows, the better you can direct AI to handle the tedious parts while you focus on the decisions that matter.
Here is the honest tension: you could spend weeks learning every feature of GitHub, or you could start collaborating now and learn as you go. Neither extreme is right. Know enough to set up a clean workflow — branches, PRs, reviews — and then let the doing teach you the rest. AI agents expand what you can accomplish in a day, but they cannot replace the judgment you build by actually working with other people on real code. That judgment is what makes you valuable on a team.
Additional Resources#
GitHub Pull Requests Documentation — Official guide to creating, reviewing, and merging pull requests
GitHub Issues Documentation — How to use issues for tracking bugs, features, and project planning
Conventional Commits — A specification for writing structured, meaningful commit messages
Next Steps#
In the next module, we’ll automate testing with GitHub Actions.