Submitting PRs to GitHub Open Source Projects

· 1 min read

Working on your own projects on GitHub is relatively simple, but how to collaborate and contribute to open source projects is more interesting. Here I’m documenting the experience I’ve accumulated contributing to open source projects like inshellisense.

https://static.1991421.cn/2024/2024-03-17-144331.png

Using the inshellisense project as an example

  1. Fork the open source project, microsoft/inshellisense => alanhg/inshellisense

  2. Create a new branch, such as fix/file-template, for development

    • Update unit tests if available, ensure tests pass
    • Don’t use the main branch directly because the main branch is used to sync project updates, avoiding situations where the original project gets new commits during development
    • Creating a new branch also allows better use of branch names to indicate whether the changes are features, fixes, etc.
  3. Commit to the upstream repository alanhg/inshellisense

  4. If the open source project microsoft/inshellisense has updates, pull the updates using Sync fork

  5. Rebase the fix/file-template branch with the main branch to ensure it’s up to date

  6. Push again to the upstream repository alanhg/inshellisense

  7. Initiate a Pull Request, describe the changes in detail, and wait for merging

    • If there are any issues during PR review, provide active feedback and resolve them
  8. Once successfully merged, celebrate 🎉

  9. You can delete the fix/file-template branch, switch to the main branch, and if there are new contributions to make, repeat step 5 for operation