How to Fork A Repository on GitHub

Jarvis Bryant
5 min readFeb 4, 2022

--

What Is GitHub?

GitHub is a web-based interface that uses Git, the open source version control software that lets multiple people make separate changes to web pages at the same time.

GitHub allows multiple developers to work on a single project at the same time. This reduces the risk of duplicative or conflicting work, and can help decrease production time. With GitHub, developers can build code, track changes, and innovate solutions to problems that might arise during the site development process simultaneously. Non-developers can also use it to create, edit, and update website content.

About this Hands-On Project:

To complete this project you will need access to a few tools that are used in tech jobs everyday. You will need Internet Connectivity, A Command Line Terminal, Centos 7 server, Vim (highly configurable text editor), A GitHub account, Access to an account with sudo (Super User Do) privileges. This project can be completed in 6 steps. I will break down each step in this article. Once you have aligned all of your tools for this project, it’s time to get started.

(1) Fork The Repository

A fork is a copy of a repository. Forking a repository allows you to freely experiment with changes without affecting the original project. Visit the project page for the repository that you would like to fork on GitHub. Click the fork icon on your GitHub page.

(2) Clone the forked repo to your local server environment

You can clone or fork a repository with GitHub Desktop to create a local repository on your computer. You can create a local copy of any repository on GitHub that you have access to by cloning the repository. Clone the repository to your local machine by clicking CODE on your GitHub profile screen. You will see a link under HTTPS, copy that link.

Then Enter the command git clone(Paste https link you copied from your github page behind the command). This command will create a directory with your project files inside. You will see “done” when it is complete

(3) Using Vim, create a changed in the file that is in the repo directory

Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems. Vim is often called a “programmer’s editor,” and so useful for programming that many consider it an entire IDE( Integrated Development Environment) .

To use Vim properly for this project, You must change your current directory to the directory that has the file you would like to edit with in. Enter this command vim <filename>(enter your file name without the <> symbols). I will provide and example of what was done.

The Directory was changed to LevelUpTeam-JB.

This command will open vim with the file “linux.sh”. From there, you can edit the file, save the changes you made and exit vim.

(4) Save the file and add to your local repo, then commit the file

Save your file in vim and exit vim with the command :wq. Now it’s time to commit the file you just made a change to.

The command (git commit -a -m) will allow you to commit your changes and notate what you did for the other contributors to see. You will be prompted to “Please tell me who you are”. You will enter both command examples shown below under “Run”, git config — global user.email”you@example.com” and git config — global user,name “Your Name” but with your email address and your user name from your GitHub account. After committing, it gets pushed to your local Repo.

(5) Push the file back to your own github repo

Now it’s time to push the file back to your GitHub repository. In order to complete this step you need to access to your GitHub developer settings and a few commands in your terminal.

The first thing we will do is create a personal access token in GitHub. This is an alternative to using passwords for authentication to GitHub when using the GitHub API. GitHub APIs allow you to create and manage repositories, branches, issues, pull requests, and many more.

Go to your: Settings|Developer Settings|Personal Access Token| Give the Token a name|Select Access Privileges|Generate new token and Copy the token|

Let’s push our changes back to GitHub. Establish a remote connection with the GitHub repo using the command git remote and push the file back to GitHub using the command git push<remote name>.

You have pushed your file back to GitHub and now it’s time to finish your last step!

(6) Send a pull request to merge with your production repository

The file has been pushed and we will see the changed file added to Github. Next, we will click on the repo you want to add your changed file to. Create a pull request to show others within that repository what you did and push it back to the branch.

Create a Pull Request by clicking “New Pull Request”. Once a request is made the repo owner will look through your changes and approve it to merge your contributions to their original project. Once complete you will see your open pull request and you can then wait for approval.

The repository developer can now see your contributions and may or may not merge them with the master file. Congratulations! The project is complete and have successfully forked a repository on GitHub!

--

--

Jarvis Bryant
Jarvis Bryant

Written by Jarvis Bryant

US Army | Professional Services DevOps Consultant | DevOps Engineer | https://www.linkedin.com/in/jarvis-bryant

No responses yet