At work, you sometimes need to create a new pull request for each project. Most of the time, you will need to create multiple pull requests within one repository. Here are a few rules to keep in mind as you make multiple pull requests in one repo to make the code review process go smoothly.
How to create new pull requests for Workgroup projects
- Make sure that pull requests for previous projects are merged into the main branch.
- Switch to the main branch:
git checkout main
- Pull all changes:
git pull
- Create a new branch based on the main branch:
git checkout -b <NEW_BRANCH_NAME>
The above process is a regular process and should be all that you need to do for the majority of your projects. However, check the edge case described below.
If your previous pull request is still under review
- Switch to the branch that is under review (as it is the freshest branch):
git checkout <PREVIOUS_PROJECT_BRANCH_NAME>
- Pull all changes:
git pull
- Create a new branch based on the freshest branch:
git checkout -b <NEW_BRANCH_NAME>
- Continue working on your new branch while waiting for your previous project’s approval.
Once your previous project is approved
- Merge the pull request with your previous project into the main branch.
- Switch to the main branch:
git checkout main
- Pull all changes:
git pull
- Switch to your new branch:
git checkout <NEW_BRANCH_NAME>
- Merge changes from the main branch:
git merge main
- Congratulations! Now your current project is based on the freshest version of the main branch.
- Under specific circumstances, you might have problems with merging at this point. If you can see any conflicts, read this lesson and try to solve them.
Leave a Reply