| # | Section |
|---|---|
| 1 | Collaborate: two models |
| 2 | Fork and clone |
| 3 | Synchronize your fork (upstream) |
| 4 | Issues |
| 5 | Team good practices |
| 6 | Quiz — Collaborative workflow |
| 7 | Practice — Contribute via a fork |
| 8 | Summary |
To work with several people on a repository, there are two main collaboration models. The choice depends mainly on who is allowed to write in the repository.
| Model | Principle | Typical case |
|---|---|---|
| Shared branch | Every member has write access; each person creates branches in the same repository | Internal team, company |
| Fork & pull | You copy the repository onto your own account, you work there, then you propose a PR toward the original | Open source, external contributors |
In a company, you almost always use the shared branch (seen in lessons 01–03). To contribute to an open-source project you are not a member of, you go through the fork.
A fork is a personal copy of a repository on your GitHub account. You have every right there, without touching the original. The clone, on the other hand, downloads a repository onto your local machine.
Do not confuse:
| Term | Where? | Action |
|---|---|---|
| Fork | On GitHub | Copies the repository onto your account |
| Clone | From GitHub to your PC | Downloads the repository locally |
| origin | Your remote fork | Where you push |
| upstream | The original repository | The source you follow |
# 1. Forking is done via the "Fork" button on GitHub (or the CLI)
gh repo fork projet/app --clone
# Manual equivalent after a fork:
# 2. Clone YOUR fork
git clone https://github.com/vous/app.git
cd app
# 3. Check the remote
git remote -v
# origin https://github.com/vous/app.git (fetch/push)The fork is your “sandbox”: you can break everything without risk for the original project. When your work is ready, a pull request proposes it to the maintainer, who decides whether to accept it.
🔧 Mini-exercise — With gh, fork the repository projet/app and clone it onto your machine in a single command.
gh repo fork projet/app --clone
While you work, the original repository evolves. Your fork does not update itself. You must add an upstream remote pointing to the original, then fetch its changes regularly.
# 1. Declare the original repository as 'upstream'
git remote add upstream https://github.com/projet/app.git
# 2. Fetch its latest changes
git fetch upstream
# 3. Update your local main
git switch main
git merge upstream/main
# 4. Push into your own fork
git push origin main| Remote | Role | Direction of use |
|---|---|---|
origin | Your fork | push your work |
upstream | Original repository | fetch other people's updates |
Syncing early and often with
upstreamprevents your fork from “drifting” away from the project. The longer you wait, the more conflicts there will be on the day of the PR.
🔧 Mini-exercise — Write the command to declare the original repository https://github.com/projet/app.git as the upstream remote.
git remote add upstream https://github.com/projet/app.git
An issue is a ticket: a place to report a bug, propose a feature, or ask a question. It is the tracking system of a GitHub project.
What you put in a good bug issue:
| Element | Example |
|---|---|
| Clear title | “Crash on click on Export” |
| Steps to reproduce | 1. Open X, 2. click Y… |
| Expected behavior | “The file downloads” |
| Observed behavior | “The application closes” |
| Environment | OS, browser, version |
# Create an issue from the terminal
gh issue create --title "Crash on click on Export" \
--body "Steps: 1) open X 2) click Export → the app closes."
# List open issues
gh issue list
# Link a PR to an issue: in the PR description
# Closes #42 → automatically closes issue #42 on mergeLabels organize issues: bug, enhancement, documentation, good first issue, help wanted…
Issues turn “we should fix that someday” into traceable and discussable tasks. Linking a PR with
Closes #Ncloses the issue automatically on merge: zero forgotten tickets.
🔧 Mini-exercise — With gh, create an issue titled “Crash on click on Export”.
gh issue create --title "Crash on click on Export" --body "The app closes on click on Export."
Beyond the commands, collaborating effectively rests on shared conventions. Here are the ones that make the difference.
| Good practice | In practice |
|---|---|
| Clear commit messages | “Fix the VAT calculation”, not “update” |
| Naming convention | feature/, fix/, docs/ for branches |
| Short branches | Integrate early to limit conflicts |
| Small reviewed PRs | Serious review, fewer bugs |
main always deployable | You never break the main branch |
A README + CONTRIBUTING file | Documents how to contribute |
The “Conventional Commits” standard, very widespread:
git commit -m "feat: add CSV export"
git commit -m "fix: fix the crash on login"
git commit -m "docs: update the README"
git commit -m "refactor: simplify the payment service"| Prefix | Meaning |
|---|---|
feat: | New feature |
fix: | Bug fix |
docs: | Documentation |
refactor: | Rewrite without changing behavior |
test: | Addition or modification of tests |
A team that shares conventions does not need to concert constantly: the code, the commits, and the branches “speak” the same language. That is collaborative fluidity.
🔧 Mini-exercise — You just added CSV export. Write the commit message in Conventional Commits format.
git commit -m "feat: add CSV export" (feat: prefix for a new feature).
Question 1: What is a fork?
a) A merge of two branches
b) A personal copy of a repository on your GitHub account
c) A type of conflict
d) A deletion of the history
Answer: b) — A fork copies the repository onto your account; you work there freely without touching the original.
Question 2: What is the difference between origin and upstream in the fork & pull model?
a) None, they are synonyms
b) origin is your fork, upstream is the original repository
c) origin is local, upstream is on your disk
d) upstream is used to delete branches
Answer: b) — You push toward origin (your fork) and you fetch updates from upstream (the original).
Question 3: What is an issue for?
a) Compiling the code
b) Reporting a bug, proposing a feature, or discussing a task
c) Automatically merging branches
d) Cloning a repository
Answer: b) — An issue is a tracking ticket: bug, idea, question, organized by labels.
Question 4: What does Closes #42 do in a pull request description?
a) Deletes commit 42
b) Automatically closes issue #42 when the PR is merged
c) Opens a new issue
d) Cancels the PR
Answer: b) — The Closes keyword (or Fixes) links the PR to the issue and closes it on merge.
Question 5: What does the commit prefix fix: mean in Conventional Commits?
a) A new feature
b) A bug fix
c) Documentation
d) A test
Answer: b) — fix: indicates a bug fix; feat: a feature, docs: documentation.
You want to contribute to an open-source project projet/app of which you are not a member. Complete the full cycle of the fork & pull model:
upstream remote and synchronize your main.# 1. Fork + clone
gh repo fork projet/app --clone
cd app
# 2. Add upstream and synchronize
git remote add upstream https://github.com/projet/app.git
git fetch upstream
git switch main
git merge upstream/main
git push origin main
# 3. Branch, commit, push
git switch -c fix/correction-typo-readme
# ... README file correction ...
git commit -am "fix: fix a typo in the README"
git push -u origin fix/correction-typo-readme
# 4. Open the PR toward the ORIGINAL repository
gh pr create --repo projet/app \
--base main --head vous:fix/correction-typo-readme \
--title "fix: typo in the README" \
--body "Fixes a typo. Closes #8"Expected result:
| Step | Verification |
|---|---|
| Fork created | The repository appears under github.com/vous/app |
upstream added | git remote -v lists origin and upstream |
| Branch pushed | The branch exists in your fork (origin) |
| PR opened | The PR targets projet/app:main from vous:fix/... |
| Issue linked | Closes #8 will close the issue on merge by the maintainer |
$ git remote -v
origin https://github.com/vous/app.git (push)
upstream https://github.com/projet/app.git (fetch)The PR goes from your branch (
vous:fix/...) toward themainof the original repository. The maintainer reviews it and decides whether to merge: you just contributed to open source without ever having write access on the project.
Closes #N links and closes on merge.main.feat:, fix:, docs:…) standardize the messages.This module 02 is finished: you now know how to branch, merge, open pull requests, and collaborate at scale. Module 03 continues the DevOps path with continuous integration (CI/CD), which will automate tests and deployments from these same pull requests.
All rights reserved. Any reproduction, distribution, use or adaptation of this course, in whole or in part, is strictly prohibited without the prior written authorization of Dr. Haythem REHOUMA.
Course created by Dr. Haythem REHOUMA — Development and Deployment of Data Solutions