While using Git/Github, there's a need to be updated with the latest commits.
Forking a repository means creating your own version of the repo where you can make whatever changes you want. It's like a personal copy. It won't affect the original product. With forks, you can change/modify whatever you want and experiment around code freely and fearlessly! Cool right? Forking has nothing to do with Git, it is a feature of Github. Thanks to this awesome feature otherwise we wouldn't be able to play around with code at such individual levels.
In cloning, the copy of the repository is made at your local machine unlike fork where the copy is restricted to a repository on Github only. This is the main difference between fork and clone.
You started contributing to a project so you forked it, began working on an issue. In the mean time, other developers of the project pushed changes to the original repo from where you had forked. Now, you're done working and want to open a PR. When you go on Github, you see
This branch is 5701 commits behind original:master
Now, you need to update your forked repo
(Assuming you've cloned already)
Switching to the master branch
git checkout master
Checking remote versions
git remote -v
git remote add upstream link
link is of the original repo from where you forked!
upstream is the master branch of the original repo
git remote set-url origin SSH of original repo
Fetching all the changes from the upstream
git fetch upstream
git merge upstream/master
Finallyy pushing your changes
You're all set to open that PR!