A Git Workflow For Open Source Contribution
- Read the contributing guide for the project.
- Fork the original (“upstream”) repository into your own GitHub account by using the “fork” button at the top of that repo’s page on GitHub.
- Clone your forked repository onto your local machine using the following command:
git clone <SSH key / URL> - Set up the upstream repository as another remote by using the following command inside the project folder:
git remote add upstream <the original repo that you forked e.g. git@github.com:TheOdinProject/curriculum.git>
Ongoing Workflow
- Create a new feature branch
- When you’re done with your feature, fetch the most updated copy of the upstream repository using the following command:
git fetch upstream - Merge the upstream’s changes into your local version of the main branch using the following commands:
git checkout main git merge upstream/mainOr
git pull upstream main - Switch back to your feature branch using the following command:
git checkout your_feature_name - Merge the main branch into your feature branch to resolve conflicts, if any, using the following command:
git merge main - Resolve any merge conflicts that arise. If you need help, check out this article on resolving merge conflicts.
- Send your feature branch back up to your origin (your fork of the upstream repository) by using the following command:
git push origin your_feature_name - If you have completed an assigned issue, submit a pull request (PR) to merge your feature branch into the original upstream repository’s main branch using GitHub’s interface.