Suppose I clone Company C's repo of Project X from github to my local machine. I create a branch for myself locally, do some work on it and make commits to my branch locally.
Now I want to make a pull request to Company C, but I realize that I should have done a fork on gitub to create my own repo of Project X and cloned that instead of Company C's repo.
How do I recover from this without cloning my fork locally and starting over by copying files manually? I'd like to use git's magic to save myself.
You need to create a fork for every repository you contribute to... but creating branches in your fork allows you to work one more than one PR at once for the upstream repo. You don't need 20 forks from the same repo to contribute with 20 PRs.
You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com.
If the original repository is deleted, the fork remains. The question is about GitHub!
A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project.
If you want to follow the development of the project you've cloned, by convention, we add a upstream
remote in addition to your origin
remote. So you have to:
Rename the current origin
remote (that track the upstream project) with a new name like upstream
.
git remote rename origin upstream
Add your personal forked GitHub project as the origin
remote.
git remote add origin <URL of your personal github fork>
The idea behind that is to follow the naming conventions of origin
for your personal repository and upstream
for the project repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With