Github pull requests - Garuk-solutions/knowledge-base GitHub Wiki

How to Submit Pull Requests

Pull requests are a way for developers to collaborate and contribute to open-source projects. They allow changes made in a fork of a project to be merged into the original repository. In this guide, we will go through the steps to submit a pull request on GitHub.

Prerequisites

  • Before submitting a pull request, you will need:

  • A GitHub account

  • A fork of the repository you want to contribute to

  • Basic knowledge of Git and GitHub

Steps

  1. Create a fork of the repository: If you haven't already, create a fork of the repository you want to contribute to by clicking the "Fork" button on the repository's page. This will create a copy of the repository in your own GitHub account.

  2. Clone the forked repository: Clone the forked repository to your local machine using the git clone command. This will create a local copy of the repository on your computer.

  3. Create a new branch: Create a new branch to work on using the git checkout -b branchname.

    Branch naming conventions

    • Your branch name should be descriptive and concise.
    • Use your organization identifier as a prefix to your branch name.
    • eg: 20456/feature/branch-name
    • eg: 20456/bugfix/branch-name
    • eg: 20456/fix/branch-name
    • eg: 20456/issue/branch-name
    • eg: 20456/chore/branch-name
    • eg: 20456/refactor/branch-name
    • eg: 20456/test/branch-name

    Give the branch a descriptive name that summarizes the changes you are making.

  4. Make your changes: Make your changes to the code, documentation, or any other relevant files in your local branch.

  5. Commit your changes: Once you have made your changes, commit them to your local branch using the git commit command. Be sure to include a clear commit message that describes the changes you have made.

  6. Push your changes to GitHub: Push your changes to your forked repository on GitHub using the git push command. This will update the branch in your forked repository with your changes.

  7. Create a pull request: On your forked repository's page, click the "New pull request" button. Select the branch you want to merge and the branch you want to merge it into. GitHub will show you the changes that will be made. Write a clear description of the changes you have made and click "Create pull request".

  8. Wait for review: The maintainers of the original repository will review your pull request and provide feedback if necessary. They may request changes or ask for more information. Be patient and responsive to their feedback.

  9. Merge the pull request: Once the maintainers have approved your changes, they will merge your pull request into the original repository. Congratulations!

IMPORTANT: Delete your branch after merging

Why?

  • It keeps the repository clean and easy to navigate.
  • It helps you avoid merge conflicts.

How?

  • Delete the branch from your local repository.

    git branch -d branchname
    
  • Delete the branch from your remote repository.

    git push origin --delete branchname
    

IMPORTANT: Create a new branch for every new feature or bug fix

You must always create a new branch for every new feature or bug fix. ( This is because you should never work on the same branch as someone else. If you do, you will run into merge conflicts.)

Repeat steps 3-9 for every new feature or bug fix.

Resources

⚠️ **GitHub.com Fallback** ⚠️