Skip to content

Fork And Pull

Alex Verkerk edited this page Mar 15, 2021 · 2 revisions

Fork-and-Pull (and how it differs to just local/remote)

What is forking & why do we do it?

This is simply making a copy of a remote repository and adding it to your account. It retains a link to the original (upstream) repository.

We fork to basically allow us to have our own copy of a repository where we can mess with our git history as much as we want, and do dumb stuff to the repo. We could force push, amend, rebase & reset, all without affecting the history of the original upstream.

and-Pull

This part of the Fork-and-Pull workflow is when you open a Pull Request from your fork, requesting that the upstream repository merge your changes in. This allows ownership and administration, plus reviews, to be managed by the upstream repository and their team of approved administrators while allowing other developers the freedom to propose changes to the upstream repository.

Crucial setup

Once you have forked a repository, the first thing you'll want to do is to clone it locally with git clone https//github.com/<username>/<forkedrepo>.git.

Once you have done that, set up the upstream repository as a source you can pull from. You can do this with git remote add upstream https//github.com/<original repo's user>/<forkedrepo>.git.

Now, you can pull changes from your upstream repository directly down to your local repository with git pull upstream main and push them to your own remote repository. This link is great for explaining what's going on.

IMPORTANT:

Make sure that you do feature branches off your personal fork so you can keep your forks main branch up to date without messy merge commits!

Clone this wiki locally