How to edit a Forked Repo from GitHub…

If you’d like to contribute to a repo on GitHub via forking, this is for you!

Before we get started, here is what you will need:

1) A GitHub account
2) A Personal Access Token (found under developer settings)
3) CentOS 7 (That is what we will use in this project)
4) Git Installed and Configured to your local command center
* Configure username, email, and “vim” as your default editor

Step 1. Sign into your GITHUB account and find the repository you plan to “Fork”. In this example, we will be using a, “Level Up in Tech Repo”.

Navigate to the “fork” icon on the upper right-hand side of the GitHub website.

Then follow up with “create fork”

Step 2. Copy the new HTTPS to clone the fork into your local server by clicking the “code” icon.

Step 3. Clone the repository using the following command in your CLI:

git clone https://github.com/username/reponame <local_repo_path>

For us, the command is (something similar to):

git clone https://github.com/Deign001/LVLUpTeam.git

Step 4. Change directories to the newly cloned repo using the following command: cd <local_repo_path>

For us, this is:

cd /home/dane/LevelUpTeam/

Step 5. Once you are in the cloned repo, you can list the files, and edit with vim. The only file listed for us is called, “linux.sh”.

To edit, enter the command

vim linux.sh

Then when you are in the file type “i” to insert, then save and quit with “wq”.

On the right picture, I added the second line down in blue... "#Testing 1, 2, 3 - LevelUp Team Red!"

Here are the before and after edit shots…

Step 6. Next, let’s check the status by entering:

git status

You can see our file has been modified…

Step 7. Add the modified file with: git add <file name>

For us, this is:

git add linux.sh

Step 8. Commit your changes with: git add -m “add description of modifications here”

Again, for us this will be:

git commit -m “added encouraging word to team red”* We add comments, so others will know what you did to the file.

Step 9. Then we will “push” the file back to your own GitHub repo. To do this, use the command:

git push -u origin main

When you enter this in, you will be prompted to enter your GitHub username, and your password. Make sure to use your personal access token from GitHub for the password. Steps 7, 8, and 9 can be seen here:

Step 9. Log back into your GitHub account, and you will find the new file you pushed to your repo!

In order to send a pull request to merge with the original repo, you will go back to the main repository, click “Create Pull Request,” then create a new pull request.

You can click on the commits to see what changed from the original script (In green), and what you are asking the authors of the main repository to change within the main source code.

Now you……….. wait!

Eventually, you will find out if your pull request gets published or denied.

I hope you found this helpful as we learned how to use GitHub & Git, to edit a forked repository!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Dane Forslund

Dane Forslund

DevOps | Cloud | AWS enthusiast. I believe my most successful moments have derived from patient leadership, proactive resolve, and often adversity.