Attending the "Getting Started with Open Source" talk at RC today, inspired me to finally figure out how to keep forks up-to-date.
- Always make your changes in a branch
- this way, you can,
- keep the main branch of the fork in sync with upstream
- ?
- this way, you can,
- Add an upstream url if not already present
- check current remote urls with
git remote -v
- if upstream entry not present, add with
git remote add upstream repoUrl.git
- for example,
git remote add upstream https://github.com/octocat/Spoon-Knife.git
- for example,
- check current remote urls with
- Get the current status? of upstream with
git fetch upstream
- Switch to
main
branch of local repository withgit switch main
orgit checkout main
- in some repositories, the main branch is called
master
- in some repositories, the main branch is called
- Merge changes from upstream with
git merge upstream/main
- this brings the
main
branch of your local repository up to date with the upstream - alternatively,
git rebase upstream/main
can be used. (Not sure which is better).
- this brings the
- Push changes to your fork (origin) with
git push
- this brings the
main
branch of your origin repository up to date with the upstream
- this brings the
Resources used (in addition to talk):