Git Collaboration on GitHub: Forks, Branches, and Pull Requests
GitHub collaboration is the practice of contributing to shared or third-party repositories using Git’s distributed workflow: you fork a repository (copy it to your own account), create a branch for your changes, then open a pull request so the maintainer can review and merge them. Small teams with write access can skip forking and collaborate directly on branches within a shared repository.
In my post “GIT in 10 minutes”, I have covered
the basics of Git setup and a few workflow commands to get started with using Git (version control system).
As promised, I will go into the topic of how to use Git for collaborative work.
Mainly, I will focus on contributions to other repositories, for instance,
open-source or projects of your colleagues and friends.
Let’s go!
GitHub Collaboration Models: Forking vs Shared Repository
As explained in GitHub documentation, GitHub supports two ways of collaborative work:
- Forking. You create a repository fork, which essentially copies a repository to your own
GitHub account. You do not need to have any permissions for the copied repository.
The repository owner can accept your pull request and merge your changes into the original repository.
- Shared repository. In small teams, you can add project collaborators, who usually work on their own
branches and push their contributions directly. Pull requests still let you review the code and comment on proposed changes before merging.
Forking and Pull Requests: Step-by-Step Git Workflow
With forks, you can make code changes without affecting the parent repository.
Let’s call the parent repository upstream and your own (forked) repository origin.
To add an upstream repository, run:
Syncing Your Fork with the Upstream Repository
🔒 Subscribe to keep reading.
Shared Repository
🔒 Subscribe to keep reading.
Conclusion: GitHub Collaboration Workflow Summary
🔒 Subscribe to keep reading.
References
🔒 Subscribe to keep reading.
You've hit a Deep Dive tutorial.
I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):
Full content temporarily unavailable — refresh in a moment
Already a subscriber? Use the magic link from your last newsletter, or reset your password.
Log in to unlock
New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.