Forking Workflow in Open Source Ecosystem
Last Updated :
14 Jun, 2024
In the Open Source ecosystem, Git and Github are widely used for efficiently managing large projects and collaborating with other developers worldwide. Hence a general Forking Workflow is followed by every developer who is contributing to these Open Source Projects. So let's deep dive to look at how exactly this Working by Forking works in an Open Source Ecosystem.
Forking a repository and Cloning it in the local environment
Just visit the Open Source Project's Github page you want to contribute, then after choosing the particular repository just click on the `Fork` button situated at the top right corner. Now that you have created your own copy of that repository by forking it, let's clone your forked repository in the local machine by running the following command:
command: git clone https://github.com/your_username/forked_project.git
example: git clone https://github.com/Aniruddha-Shriwant/techdocs.git
Adding 'upstream' repository to the list of remotesÂ
Upstream is a repository from where you have forked your local copy of the project. Now to keep your fork up to date and to sync it with the original 'upstream' repository let's add a new remote named upstream:
git remote add upstream https://github.com/accordproject/techdocs.git
You can verify the remote by running theÂ
git remove -v

Fetching from upstream remoteÂ
To update your fork with the latest upstream changes, you will need to fetch the upstream repo's branches and its latest commits using the git fetch command
git fetch upstream
Now check out to your own master branch and merge upstream repo's master branch:
git checkout master
git merge upstream/master
Now your local master branch is up to date with everything updated upstream.
Creating a new branch
Whenever you begin working on a new feature/bug fix, it's important to create a separate new branch not only because it's a proper git etiquette but you can keep your changes separate from the master branch and can easily manage multiple pull requests submitted. To create a new branch, checkout to master branch first as we want our new branch to come from the master branch and then create your new branch and edit your changes accordingly
git checkout master
git checkout -b yourNewBranch //This command will create a new branch and then checkout in it
Rebasing your branch before making Pull Request
While working on your development branch if any new commits are made in the upstream's master branch then you will need to rebase your branch so that maintainers can merge your PullRequest easily and any conflicts would be avoided in advance.
Fetch upstream master and then merge it with your local repository's master branch:
git fetch upstream
git checkout master
git merge upstream/master
Rebase your development branch with the master branch:
git checkout yourNewBranch // yourNewBranch = your development branch that you have created earlier
git rebase master
After rebasing your branch you are ready to push those changes and create a Pull Request on Github.
Conclusion
To conclude, Mastering this workflow etiquette will help you in your Open Source journey and you won't face any issues which beginner faces while making their contributions to Open Source Projects.
Similar Reads
Git Workflows With Open Source Collaboration Open source is a space where people can modify and design something that is publiclycaly accessible to everyone. Software or codebases that are open source facilitate collaboration and innovation, which is not just limited to a team, but the whole public. GitHub is a platform that houses a wide rang
10 min read
How to Contribute to Open Source? Contributing to open-source projects is a rewarding way to enhance your skills, gain practical experience, and give back to the developer community. Open-source projects welcome contributions from developers of all levels, and getting started is easier than you might think. In this article, we will
10 min read
Everything You Need to Know About Open Source Development Open source development is a collaborative approach to software development where the source code is made publicly available. This model allows anyone to view, modify, and distribute the code, that can lead to high-quality, innovative software. In this article, we will explore what open source devel
9 min read
Advance Git Sheet For Open Source Contributors Contributing to open-source projects is a fantastic way to enhance your coding skills, collaborate with a large community, and give back to the tech world. However, navigating Git can be challenging for many. This advanced Git cheat sheet aims to equip open-source contributors with essential command
4 min read
Git Workflows For Agile Development Teams Git Flow is a branching model that involves the use of different types of branches based on the objective of the task. GitFlow WorkflowTable of Content The Git Flow strategy consists of the following branchesAgile Development LifecycleSteps to Integrate Git In Your Agile Workflow Choosing the Right
6 min read