Context
While working on OSS project, I got a new PR with a contribution from a fork. Before merging, I wanted to push some linting changes on the existing branch in the fork.
Solution
- Add the fork as another remote origin:
git remote add contrib <fork_url>
- Checkout a new branch (e.g
main
) that tracks the PR source branch from the fork:
git checkout -b contrib-main contrib/main
- After committing my changes, push to the source branch (
main
in this example):
git push contrib HEAD:main