GitHub: Forking & Pull Requests

Toni Benn
4 min readNov 28, 2021

--

A beginner’s guide to navigating Github

Only 48 hours after Thanksgiving and here I am, taking on the challenge of navigating through one of the most widely used remote repository services in the world…Github 😱. I’d heard about Github and worked with it a little in the past but hadn’t a clue what any of the buttons meant nor what they did 🤔🤨. But earlier this week as I started learning about Git — a version control system that tracks the changes you make to files — it was only right that my cohort and I would have to face the beast (aka Github lol).

What is Git?

Git is a very important tool you should utilize while working in the terminal because you’re able to make changes to a file and save them or “commit” them so all activity on that file can be tracked. A repository is where these files are held and managed and in a place like Github, there are virtual repositories where you’re able to transfer the content from files in your local repository, and push them up to a repository in Github.

What is Github?

Github is a remote repository service that permits frequent collaboration on a project between team members so that continuous changes can be made. Collaborators on a project are able to submit a pull request up to the owner of a Github project for the content from their repository to be pushed up ⬆️. This is what I was tasked with doing this week as a student in Level Up In Tech and below I’m going to walk you through how to fork the information from a repository in Github, add it to your local machine, make changes, and send them back up to the main Github repository using a pull request.

Step 1

Fork a copy of the repository you’d like to work on.

Fork a copy of the repository to your Github account

Step 2

Note that a copy of the repository has been copied to your account (tonibtech/LevelUpTeam).Copy the HTTPS link to your clipboard because you’ll need it when you’re in the terminal.

Copy this link to your clipboard. You’ll need it when we are in our terminal

Step 3

Switch to your terminal and create an empty directory. This directory is where you will house the copy you’ve made of the of the repository in Github.

mkdir luitproject2

Create a new directory
Quickly switch into the directory

cd luitproject2

*If you’re unable to make a directory using the mkdir <name of dir>add sudo to the beginning of the command to grant yourself elevated permissions.*

Step 4

Create a clone of the repository using git clone <github_HTTPS_link>

Make a clone of the repository

Step 5

Once you’ve made a clone of the repository, you’ll see it listed in your files when you hit the ls command.

Now, switch to the repository using cd <repository_name>

Step 6

Find the file you’d like to edit, and do your thing 😎. Below is an example of what I did but your project and file will be different.

Linux.sh is the file we’ll be editing in the vim text editor
Here I’m editing the file linux.sh using vim

Step 7

Next you’re going to commit the changes you made to the file by first using git add <name_of_file> then git commit -m “insert_message_here”

Here we’re making a commit to the file linux.sh

Step 8

Now we’re going to push our edits to the linux.sh file to up to our remote repository in Github using git push -u origin main (Github now uses main rather than master).

Insert your username and password (access token from Github)

*If you’re having trouble pushing your updated file using git push -u origin main , try git push -f origin main *

Now when you return to Github, you’ll see that changes have been made to the copy of the repository you forked earlier.

Step 9

We’re now going to submit a pull request to merge the change we made up to the main branch.

In the image below, I’ve actually already submitted my pull request but once you hit the “new pull request” button, everything is pretty straight forward from there.

Pat yourself on the back because you’ve just submitted your first pull request 👏🏾!!

--

--