I am trying to understand / visualize the elements that come with forking a repo. My starting reference is this help page.
1st Question:
When I forked a repo e.g. Spoon-Knife on GitHub (i.e. clicked the Fork button on their site), does it mean the Spoon-Knife is copied to my GitHub account? Did a real copy actually happen or is it just a concept?
2nd Question:
The next step in the help page is to do a clone:
$ git clone [email protected]:username/Spoon-Knife.git
This command made a copy of the source in my local machine. Did it clone from the forked / copied repo in my GitHub account (please see my first question)? Or, from the original Spoon-Knife repo?
3rd Question:
Step about configuring remotes:
When a repo is cloned, it has a default remote called
origin
that points to your fork on GitHub, not the original repo it was forked from. To keep track of the original repo, you need to add another remote namedupstream
.
So, is origin
some kind of "proxy" between our local copy and the repo copy on my GitHub account? And, how about upstream
?
Thanks beforehand for your help.
All you are doing when you "fork" is to effectively create a branch on their git repository that you can check into.
Your local copy that you clone to is just cloned from and linked to the branch you created on git-hub. Remember a branch is just a pointer to a commit object, so when you "forked" you just added a branch name on their repo that points to the current head of their master.
Remotes in git are just names to repositories at an external address. Your default "origin" is set up by git and is just a named remote. "upstream" is just another name and points to the original master that you originally branched from so that you can pull changes between master and your own branch. You can see your remotes with git remote -v
and add them easily to track any branch on any externally available git repo.
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