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.
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 firstname.lastname@example.org:umputun/remark42.git git fetch upstream git switch -c readme-for-devs upstream/master
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
- If things get problematic, set
upstreamto the preforked branch.
git remote add upstream <UPSTREAM_URL>
You mostly have only seen
originright? Alternative names such as
upstreamcan also be used.
To update your
masterbranch to be up-to-date with preforked,
git fetch upstream git pull upstream master
- To fork directly from
upstream's master branch,
git switch -c <YOUR_PREFERRED_NAME> upstream/master
- 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?