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

  1. Make sure that pull requests for previous projects are merged into the main branch.
  2. Switch to the main branch:
    • git checkout main
  3. Pull all changes:
    • git pull
  4. 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

  1. Switch to the branch that is under review (as it is the freshest branch):
    • git checkout <PREVIOUS_PROJECT_BRANCH_NAME>
  2. Pull all changes:
    • git pull
  3. Create a new branch based on the freshest branch:
    • git checkout -b <NEW_BRANCH_NAME>
  4. Continue working on your new branch while waiting for your previous project’s approval.

Once your previous project is approved

  1. Merge the pull request with your previous project into the main branch.
  2. Switch to the main branch:
    • git checkout main
  3. Pull all changes:
    • git pull
  4. Switch to your new branch:
    • git checkout <NEW_BRANCH_NAME>
  5. Merge changes from the main branch:
    • git merge main
  6. 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 conflictsread this lesson and try to solve them.

Categorized in: