TLDR
Assuming a repo main_repo/whatever and your fork forked_repo/whatever.
git clone git@main_repo/whatever.git
git remote rename origin upstream
git remote add origin git@forked_repo/whatever.git
Setting Up A Forked Repo for Easy Contributions
Have you ever contributed to an open source project? The typical process is as follows:
- Fork the repo
-
git clonethe fork - make changes against the branch and push them up
- open a PR against the main repo
Generally, this is fine. However, on faster moving projects it quickly becomes a pain keep your fork in sync with upstream changes. The only way I am familiar to get those updates is via the “Sync Fork” button on the page of the forked repo. But doing to Github every time is a pain.
Fear not there is another (IMO better) way.
- clone the main repo
git clone git@main_repo/whatever.git - rename origin to upstream
git remote rename origin upstream - fork it on github (ex:
my_repo/whatever.git) - add new origin which is fork
git remote add origin git@my_repo/whatever.git
Now you can make changes as usual, by pushing branches up to your fork and opening PRs. However, when you pull main it will pull changes from the original repo not your fork! (Pushing to main will also push to the main repo but don’t do that).