"A fork is a copy of a repository that you manage. Forks let you make changes to a project without affecting the original repository."
On the start
We have 2 repos
-
original
github/OWNER/original
-
forked
github/YOU/forked
In forked repo we can check our settings
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
On the next we need to add original repo as upstream
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Now we should see
$ git remote -v
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
> origin https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
> upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
Get changes from original to forked
git fetch upstream
git checkout main
git merge upstream/main
Creating Pull Request from forked to original
# FORKED repo
# make changes
git add .
git commit -m "message"
git push
Then go to forked repo on github and create Pull Request.
Workflow
To keep workflow clean:
✅ original → forked
⛔ forked → original (do it only when you are sure what are you doing!)
Top comments (1)
Just shared this with my class. Really great and easy to follow breakdown :)