Collaborating on GitHub: Forking, Cloning, and Creating Pull Requests

mdshamsfiroz
4 min readOct 29, 2024

--

In this blog post, we’ll walk through the process of contributing to an open-source project on GitHub. We’ll cover forking a repository, cloning it locally, making changes, and creating a pull request. This workflow is essential for collaborating on projects and contributing to the open-source community.

Step 1: Fork the Repository

  1. Log in to your GitHub account.
  2. Navigate to the repository you want to contribute to.

3. Click the “Fork” button in the top-right corner of the page.

4. GitHub will create a copy of the repository under your account.

Step 2: Clone the Forked Repository

  1. On your forked repository page, click the “Code” button.
  1. Copy the HTTPS or SSH URL provided.
  2. Open your terminal and navigate to where you want to clone the repository.
  3. Run the following command:
git clone <copied-url>

4. Change into the newly created directory:

cd <repository-name>

Step 3: Create a New Branch
It’s a good practice to create a new branch for your changes:

git checkout -b my-new-feature

Step 4: Make Your Changes

  1. Open the project in your preferred code editor.
  2. Make the desired changes to the codebase.
  3. Save your changes.

Step 5: Commit Your Changes

  1. Stage your changes:
git add .

2. Commit the changes with a descriptive message:

git commit -m "Add new feature: description of changes"

Step 6: Push Changes to Your Fork
Push your new branch and changes to your forked repository:

git push origin my-new-feature

Step 7: Create a Pull Request

  1. Go to your forked repository on GitHub.
  2. Click on “Pull requests” tab.
  3. Click the “New pull request” button.
  4. Ensure the base repository is the original project and the head repository is your fork.
  5. Select your new branch in the “compare” dropdown.
  6. Click “Create pull request”.
  7. Add a title and description explaining your changes.
  8. Click “Create pull request” to submit.

Best Practices:

  1. Always create a new branch for each feature or bug fix.
  2. Keep your commits small and focused.
  3. Write clear, concise commit messages.
  4. Follow the project’s contribution guidelines if available.
  5. Be responsive to feedback and be prepared to make additional changes.

Conclusion
By following this workflow, you’ve successfully contributed to an open-source project. You’ve forked a repository, made changes locally, and submitted those changes back to the original project through a pull request. This process is fundamental to collaborative development on GitHub and is an excellent way to contribute to the open-source community.

So, whether you’re a tech enthusiast, a professional, or just someone who wants to learn more, I invite you to follow me on this journey. Subscribe to my blog and follow me on social media to stay in the loop and never miss a post.

Together, let’s explore the exciting world of technology and all it offers. I can’t wait to connect with you!”

Connect me on Social Media: https://linktr.ee/mdshamsfiroz

Happy coding! Happy learning!

--

--

mdshamsfiroz
mdshamsfiroz

Written by mdshamsfiroz

Trying to learn tool by putting heart inside to make something

No responses yet