Fork an existing repository from GitHub, clone it locally, make some changes, and create a pull request to the original repository.

Vaibhav ParekhVaibhav Parekh
2 min read

Here's a step-by-step guide to fork an existing GitHub repository, clone it locally, make changes, and create a pull request to the original repository.

Step 1: Fork the Repository

  1. Go to the GitHub page of the repository you want to fork.

  2. Click the Fork button in the upper right corner. This creates a copy of the repository under your GitHub account.

Step 2: Clone the Forked Repository

  1. Open your terminal or command prompt.

  2. Clone your forked repository using the following command (replace USERNAME with your GitHub username and REPOSITORY_NAME with the name of the repository):

     git clone https://github.com/USERNAME/REPOSITORY_NAME.git
    
  3. Change into the cloned directory:

     cd REPOSITORY_NAME
    

Step 3: Create a New Branch

  1. It's a good practice to create a new branch for your changes:

     git checkout -b feature-branch
    

Step 4: Make Changes

  1. Open a file in your text editor, make some changes, and save the file.

  2. For example, you can edit the README.md file to add a new section or modify existing content.

Step 5: Stage and Commit Your Changes

  1. Stage your changes:

     git add README.md
    
  2. Commit your changes with a meaningful message:

     git commit -m "Update README with new information"
    

Step 6: Push the Changes to Your Fork

  1. Push your changes to the forked repository:

     git push origin feature-branch
    

Step 7: Create a Pull Request

  1. Go to the original repository on GitHub (the one you forked from).

  2. You should see a message indicating that you recently pushed a branch to your fork. Click on the Compare & pull request button.

  3. Fill out the pull request form, providing a title and description for your changes.

  4. Click the Create pull request button.

Summary

You've successfully forked a repository, cloned it locally, made changes, pushed those changes to your fork, and created a pull request to the original repository. If you have any questions or encounter issues, feel free to ask!

0
Subscribe to my newsletter

Read articles from Vaibhav Parekh directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vaibhav Parekh
Vaibhav Parekh

I am a Cloud enthusiast . Delivering continuous learnings through blogs . You have any doubts you can contact me directly don't hesitate . We all have a start and initial days of learning !!