DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

Open source contribution (PR), simultaneously

So, I thought making an open source contribution is as simple as forking and making a Pull Request; then wait for merging.

I was too naive. Merging might take time from multiple code reviews / corrections. During that, several things may happen.

  • The preforked upstream is updated.
  • You want to make another pull request unrelated to the old one.

My experience was pretty much sum up here.

Comment for #737

I still have one PR pending. How do I manage another one? Just overwrite the old PR?

What I actually did,

git remote add upstream git@github.com:umputun/remark42.git
git fetch upstream
git switch -c readme-for-devs upstream/master 
Enter fullscreen mode Exit fullscreen mode

The actual steps are a little different as I used VSCode's GUI.

So, my recommendations are

  • After forking, always make a branch. Don't edit / merge master branch directly.
  • If things get problematic, set upstream to the preforked branch.
git remote add upstream <UPSTREAM_URL>
Enter fullscreen mode Exit fullscreen mode
  • You mostly have only seen origin right? Alternative names such as heroku, staging, or upstream can also be used.

  • To update your master branch to be up-to-date with preforked,

git fetch upstream
git pull upstream master
Enter fullscreen mode Exit fullscreen mode
  • To fork directly from upstream's master branch,
git switch -c <YOUR_PREFERRED_NAME> upstream/master
Enter fullscreen mode Exit fullscreen mode
  • My thought is also, I can manage multiple unrelated updates this way too. (such as partial monorepo changes, or some commit-type-specific changes.)

Anyone has an experience to share as an open source contributor, about best practices in Git and GitHub?

Top comments (0)