Description of a fork, its benefits and git fork workflow implementation
Published on November 16, 2020 by Dai Tran
howto blog git gitworkflow fork devops
1 min READ
A fork is a copy of a repository. Forking a repository allows you to experiment with changes without affecting the original project freely. You can create a fork to suggest changes when you don’t have permission to write to the original project directly.
You can fork repositories in the following situations:
For convenience, after cloning, you’ll want to add the upstream repository (where you forked from) as a remote named upstream.
git remote add upstream {upstream_url}
When you’ve gotten your PR accepted into upstream, you’ll want to make sure your fork reflects the latest state of the repo.
It is recommended rebasing on upstream’s main branch (assuming main is the main development branch).
git fetch upstream main
git rebase upstream/main
git push origin
The forking workflow lets you isolate changes from the main repository until you’re ready to integrate them. When you’re ready, integrating code is as easy as completing a pull request.