Video in progress

Junior 🌿 Git

What is the difference between a fork on GitHub and `git clone`?

clone copies a repository to your computer. A fork creates a copy of the repository on the server itself, under your account. A fork is not a Git command, it is a GitHub/GitLab feature.

📖 Answer

You have no push rights to someone else's project (an open source library, for example). In that case:

# 1) the "Fork" button on GitHub -> github.com/you/library
git clone git@github.com:you/library.git
cd library
git remote add upstream git@github.com:original-author/library.git

# 2) you work on your own branch and push to your own fork
git switch -c fix/typo-in-docs
git push origin fix/typo-in-docs

# 3) on GitHub you open a PR from the fork to the original repository

Inside a company you usually do not fork: everyone has access to one repository and just clones it and creates branches.

You need to update the fork from upstream from time to time, otherwise you get many conflicts when you open a PR.