Git Fork
A fork is your own copy of another person's repository, made on the hosting site (GitHub, Bitbucket, GitLab). Forking is not a Git command: you click Fork on the site.
You can push to your fork freely, and send your changes back to the original project with a pull request.
Clone your fork and add the original as upstream
git clone https://github.com/your-username/hello-world.git
Cloning into 'hello-world'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 0), reused 4 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (4/4), done.
cd hello-world
git remote add upstream https://github.com/w3schools-test/hello-world.git
git remote -v
origin https://github.com/your-username/hello-world.git (fetch)
origin https://github.com/your-username/hello-world.git (push)
upstream https://github.com/w3schools-test/hello-world.git (fetch)
upstream https://github.com/w3schools-test/hello-world.git (push)
Bring new changes from the original into your fork
git fetch upstream
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
From https://github.com/w3schools-test/hello-world
* [new branch] main -> upstream/main
git merge upstream/main
Updating 1d34a75..dc23e99
Fast-forward
README.md | 1 +
1 file changed, 1 insertion(+)
git push origin main
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 16 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 361 bytes | 361.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/your-username/hello-world.git
1d34a75..dc23e99 main -> main