ETC5513: Collaborative and Reproducible Practices
Tutorial 6
🤝 Workshop: Forking, Branching, and Rebasing with Quarto
In this workshop, you’ll practice collaborative editing using branches, rebasing, and pull requests in a Quarto project.
You’ll simulate a real-world collaboration scenario: - One student makes changes to the main branch - Another student works on a feature branch - Before contributing, the second student rebases to keep history clean
🧑🤝🧑 Step 1: Pair Up
Assign roles:
- Student A = Repository owner
- Student B = Contributor
You’ll swap roles after completing the exercise.
🛠️ Step 2: Student A – Set Up the Repository
- Create a new GitHub repo named something like
quarto-rebase-demo
- ✅ Add a README file
- Clone it locally:
git clone git@github.com:your-username/quarto-rebase-demo.git
cd quarto-rebase-demo- Create a Quarto file called
collab.qmd:
---
title: "Rebase Demo"
format: html
---
# Introduction
This is a collaborative Quarto project.
# Contributions
<!-- Student sections will go here -->- Commit and push:
git add collab.qmd
git commit -m "Add initial Quarto file"
git push origin main- Share the GitHub link with Student B.
✅ Student B can now fork the project.
🍴 Step 3: Student B – Fork, Branch, and Contribute
- Fork Student A’s repository on GitHub
- Clone your fork:
git clone git@github.com:your-username/quarto-rebase-demo.git
cd quarto-rebase-demo- Create a new branch for your work:
git branch my-section
git switch my-section- Open
collab.qmdand add your section under “# Contributions”:
# Jamie’s Section
This is my contribution to the Quarto project.- Save the file, then stage and commit:
git add collab.qmd
git commit -m "Add Jamie’s section"✅ Don’t push yet — Student A will now make another change.
🧱 Step 4: Student A – Make Another Commit on main
While Student B is working, Student A adds a new section to collab.qmd:
# Instructor's Section
This section was added after Student B began work.- Save the file, then commit and push:
git add collab.qmd
git commit -m "Add instructor’s section"
git push origin main✅ Now Student B’s branch is behind main.
🔄 Step 5: Student B – Merge In Latest main
- Check your remotes:
git remote -vYou should only see one remote called origin
- Add Student A’s repo as a remote:
git remote add upstream git@github.com:student-a-username/quarto-rebase-demo.git
git fetch upstream- Check your remotes and branches again:
git remote -v
git branch -v- Rebase your branch:
git merge upstream/main- If there are any conflicts, Git will pause and show them in
collab.qmd. Edit the file and resolve them manually. It might look like this:
<<<<<<< HEAD
# Jamie’s Section
This is my contribution to the Quarto project.
=======
# Instructor's Section
This section was added after Student B began work.
>>>>>>> upstream/main- After fixing the file, run:
git add collab.qmd
git commit -m "Merge conflict in upstream"- Once merging is complete, push your changes to your fork:
git push origin main✅ Step 6: Create a Pull Request
- Go to your fork on GitHub
- Click “Compare & pull request”
- Make sure your PR is from
main→main(on Student A’s repo)
- Click Create pull request
✅ Your caught-up contribution is now ready for review!
📬 Step 7: Student A – Review and Merge
- Open the pull request
- Check the changes
- Click Merge pull request → Confirm merge
🎉 Now the main branch has clean history and includes both contributions!
✅ Summary
You now know how to:
- Fork and clone a GitHub repository
- Work on a feature branch
- Merge changes onto the latest
main - Submit a clean pull request
✨ You’ve just used a professional Git workflow!