Editing a Forked Repo Using GitHub | by Michael Cassidy | Mar, 2022

Photograph by Alex Kondratiev on Unsplash

If you wish to edit a repository from GitHub, you’ll need the next issues:

  • An account with GitHub
  • A private entry token beneath the “Developer settings” part of GitHub
  • A CLI (I can be utilizing CentOS 7)
  • Git Put in and Configured

Examine for any updates to the server:

sudo yum replace

Step 1. Fork the repository you want. On this instance I’ll use the Stage Up in Tech Repo at this net tackle:

https://github.com/LevelUpInTech/LevelUpTeam

Be sure you click on the fork icon on the higher right-hand aspect of the GitHub web site, in an effort to fork the repo.

Step 2. This can be step 1 for you, however in case you haven’t already, make certain to put in Git in your server. This may be completed with the next instructions:

sudo yum set up git

If you’re utilizing a Debian based mostly distribution, comparable to Ubuntu, you need to use the next command:

sudo apt-get set up git

After Git efficiently installs, you’ll need to configure it with the next instructions:

git config --global person.title <username>  
git config --global person.electronic mail <email_address>

This manner, the configuration recordsdata will retailer info comparable to your username, default editor, and the e-mail you need to affiliate along with your commits.

For this mission, I’ve used vim to edit the repository. To make vim your default editor, use this command:

git config --system core.editor vim

Step 3. After you might have forked the repo, it is best to be capable of copy the brand new HTTPS to clone the fork into your native server.

Step 4. Clone the repository utilizing the next command in your CLI:

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

In my case, the command was:

git clone https://github.com/Michael-Cassidy-88/LevelUpTeam.git LevelUpTeam

As you’ll be able to see, I created a clone in my residence listing. You may make one other listing if you want beforehand, to retailer the cloned repo in.

Step 5. Change directories to the newly cloned repo utilizing the next command:

cd <local_repo_path>

Step 6. As soon as you might be within the cloned repo, you’ll be able to discover the recordsdata. In my case, there’s a linux.sh script that I can be modifying utilizing vim.

Script edited

Step 7. After getting edited the script, exit vim (:wq) and add the newly saved script to your native repository. As you’ll be able to see, I checked the standing by coming into:

git standing

As soon as you might be prepared so as to add the modified file, enter the next:

git add <name_of_script>

To commit these modifications, enter:

git commit -m "some data about what you probably did to the script"

You’ll want to add a remark, so others who finally see your repo, will know what you probably did.

Step 8. Push the file again to your individual GitHub repo. To do that, use the command:

git push -u origin important

Once you enter this in, you may be prompted to enter your GitHub username, and your password. Make certain to make use of your private entry token from GitHub for the password. You might obtain this message if you don’t use your private entry token:

In any other case, it ought to look one thing like this:

Profitable

Step 9. When you log again into your GitHub account, it is possible for you to to see the brand new file you pushed to your repo.

So as to ship a pull request to merge with the unique repo, you’ll return to the primary repository, click on “Pull Requests,” then create a brand new pull request.

You possibly can click on on the commits to see what precisely you modified from the unique script, and what you might be asking the authors of the primary repository to alter inside the primary supply code.

Now you wait in your pull request to get printed or denied. Both manner, you might have hopefully discovered how you can use GitHub, and Git, to edit a forked repository.

More Posts