Merge Pull Request into forked repository

github-readme-stats is a statistics generator for GitHub profiles, allowing users to display various statistics and charts on their GitHub profile. It offers multiple customization options that can be adjusted according to user needs.

I manage my warehouse by grouping them into projects. GitHub doesn’t support warehouse grouping, so I have to achieve this by splitting them into different organizations. The latest branch of github-readme-stats cannot support statistics across different organizations’ warehouses, so I forked a branch and merged the corresponding code.

Final effect

GitHub Stats Top Languages

Original Pull Request address

Adds the ability to include data from organization repositories

Merge Pull Request into the forked repository

There are several ways to merge a Pull Request (PR) into your forked repository, depending on what you want to do

  1. Merge the PR from the upstream repository into your fork, or
  2. Merge a PR from another person’s fork into your fork, or
  3. Merge a PR opened on your fork (e.g., someone submitted a PR from their fork to you)

Here’s a common scenario: You forked a repository, and you want to merge a specific pull request from the upstream into your fork. Here’s the workflow 👇:


Method 1: Command-line method (most universal)

Step 1: Clone your own fork

git clone https://github.com/你的用户名/仓库名.git
cd 仓库名

Step 2: Add upstream (original repository address)

git remote add upstream https://github.com/原作者用户名/仓库名.git

Step 3: Fetch the upstream’s PR branch

Find the PR number you want to merge, for example, PR #123

You can pull the code for this PR like this:

git fetch upstream pull/123/head:pr-123

Step 4: Switch and Merge Branches

git checkout main    # 或者你自己的目标分支
git merge pr-123

If everything is normal, you can push to your forked GitHub repository

git push origin main

Method Two: GitHub Web Interface (Simple but Limited)

If you see a pull request on the GitHub website that is for an upstream repository, you can:

  1. Go to that PR page
  2. Click “Commits” or “Files changed” in the upper right corner to see which branch this PR is based on
  3. On your fork page, create a new branch and then manually cherry-pick the PR’s commits (this requires some Git knowledge)
  4. Or click “Open in GitHub Desktop” to merge using a graphical user interface tool

If someone has submitted a pull request for your fork

Just go directly to the PR page and click the “Merge pull request” button


Would you like me to walk you through it step-by-step based on your current situation (e.g., a PR link, whether you’re using a web page or command line)? You can also give me specific links, and I’ll help you analyze the simplest approach

Licensed under CC BY-NC-SA 4.0
Last updated on May 25, 2025 02:57
A financial IT programmer's tinkering and daily life musings
Built with Hugo
Theme Stack designed by Jimmy