π Homepage π Syllabus of Day 2 β¬ οΈ Previous: π Cloning a Repository
Forking is the process of creating a personal copy of someone elseβs repository on your own GitHub account. This allows you to freely experiment with changes without affecting the original project.
You should fork when you do NOT have collaborator access to the repository.
Go to the Repository:
Visit https://github.com/samyak-shrestha/git-repo-example.
Click the βForkβ Button:
At the top right of the page, click the Fork button.
Choose Your Account:
Select your GitHub account as the destination for the fork.
Your Fork is Created:
You now have a copy at https://github.com/<your-username>/git-repo-example
.
Fork the Repository
As described above.
git clone git@github.com:<your-username>/git-repo-example.git
cd git-repo-example
git remote add upstream git@github.com:samyak-shrestha/git-repo-example.git
git checkout -b my-feature-branch
git add .
git commit -m "Add my feature"
git push origin my-feature-branch
| Topic | Description/Goal |
|βββββββ-|βββββββββββββββββββββ|
| Fork | Click βForkβ on GitHub |
| Clone fork | git clone git@github.com:<your-username>/git-repo-example.git
|
| Add upstream | git remote add upstream git@github.com:samyak-shrestha/git-repo-example.git
|
| Create branch | git checkout -b my-feature-branch
|
| Pushing Changes | git push origin my-feature-branch
|
| Pull Requests | Open PR from your fork to the original repo |
Tip: Forking is the standard workflow for contributing to open source projects when you donβt have write access.
β‘οΈUp Next: π Opening a Pull Request (PR)