Skip to main content

Section 5.2 Getting Set Up To Collaborate

The first step to collaborating is to recognize that you usually do not have the permissions to edit others’ repositories directly. We might say that you do not have write access to those repositories. You won’t be able to edit files on GitHub like we did in Chapter 3. So how do you contribute to someone else’s repository?

Subsection 5.2.1 Forking

Recall from Chapter 4 that in order to edit files on our computer, we had to clone the respository from GitHub. Essentially, this was a copy of your repository on your computer. In order to edit someone else’s files, we need to create a copy of their repository on GitHub. Then, we edit our copied files and submit a pull request asking the moderator to incorporate our changes.
This process should seem familiar! But how do we make this copy? You can’t clone a repository on GitHub (this is a Git concept), but GitHub does provide the ability to fork. Like “commit”, “fork” is both a noun, referring to a user’s copy of the authority repo, and a verb, referring to the action of making that copy.
You may have noticed that GitHub provides a “Fork” button in the top right corner of a repo’s webpage (note that you cannot fork your own repos). See Figure 5.2.1.1 for a visual reference then proceed to try your hand at forking.
Location of the fork button on GitHub (near Watch button and Star button)
Figure 5.2.1.1. The Fork Button on GitHub
This activity focuses on forking a repo and getting a new project started that we will carry throughout this chapter: editing a file on a repository I created.
(b)
Locate the “Fork” button in the top right corner.
Note the number next to it. This indicates the number of people who have forked a repo. This also applies to the Watch (people who receive notifications for the repo) and Star buttons. A good sense of how popular and how useful the contents of the repo are can be gained from looking at these numbers (where higher is better.)
(c)
Click on the Fork button. A new webpage will appear allowing you to rename your fork and add a description. I recommend keeping the same name as the parent repository, as GitHub suggests. This will make it easier to remember what the repo is for.
That being said, you cannot have two repos with the same name. If you have been following along with the book, you might already have a repository named aboutme. In that case, you should choose a different name, but one that is close or similar to the parent repo’s.
Click on the Create Fork button.
(d)
After a few seconds, your own fork will appear! Take a look at the top left corner where the name of the repo is displayed. You should notice that your personal username and repo name are there. But underneath that, in smaller font, GitHub tells you the username and repo name from which you forked. This is useful for reminding yourself that you are working on a copy of a repository, not the authoritative one.
Congrats! You’ve just forked a repository! If you plan on collaborating with others forking will become something you get very used to.
Remember that you just created a copy of my repository. You can make all the changes you want on your copy without asking for permisson from me. But as soon as you try to update my repo, you will have to submit a pull request. A fork is where you edit some things, try some things, and break some things before making a final product of whatever it is you were working on. Then send the changes over to the main repo!