Can create a pull request by others fork repo, is it a bug or a feature?

I find I can use my account to open a pull request by use others fork repository (see this screenshot)

And as github document says :

Anyone with write access to a repository can create a pull request from user-owned fork

So is it a bug or a feature ?

1 Like

It’s a feature of Git being a distributed version control system — forks of a same repo usually share common ancestry, so they are effectively the same code base when it comes to contributing. The fact that we usually consider the “upstream” repository as the original source project is really just a convention in a distributed VCS like Git, and nothing prevents you from creating alternative “upstreams” with divergent code bases, and have a fork pointing to all of them, using branches to keep track of both the common ancestry and the divergent code.

Anyone with write access to a repository can create a pull request from user-owned fork

What the above means is that in any repository (fork or otherwise) any collaborator who has write-access privileges can create a PR from that repository to another repository (upstream or other fork, it doesn’t matter) including that same repository itself (e.g. if you need to go through a review process for your contributions).

Thanks for your explanation .

But I still confuse about this things :
1、There is a repo A and its fork repo B.
2、I don’t hava write access to both repo, only read access
3、But now I can create a pull request from repo B to repo A.

Is this a bug ? In my opinion,people should not hava the capability to operate others repo if they only have read access. What do you think ?

You should have write access to your fork, which is why you need to push your changes from your local clone (of your fork, not of the original repository) into your fork on GitHub, and only then you can create a pull request on GitHub’s WebUI. Pull requests are not part of Git, they are part of GitHub, which is why you need to create them on GitHub, not via Git commands. If you’re a collaborator to the repository than you have already write access, and don’t need to fork it since you can create PRs directly on the upstream repository. If not, you need to fork, push your changes to your fork (on a new branch) and then create the PR on the target repository (usually the usptream, i.e. original).

From your fork you can create a pull request to any repository which shares the same history of the branch you’re making the PR on. Branches are what allow Git users to keep divergent code along with the original code. What is considered the main code by someone might depend on what one is working with. E.g. let’s say that repo A is the “official” version of some program, but then someone created a variation of the same program, which is hosted on repo B. The two projects have a common history, which is what allows them to pick and chose updates from each other.

Since both A and B are connected via some common branch which they share, in your repository (let’s call it X) you can fork A, but then also add a remote pointing to B, so you’ll be able to pull changes from both, and also submit changes to both. The idea of a “central” and “official” repository is nothing more than a convention in Git, because it’s a decentralized system. Of course, we all know that certain apps have an official repository, but if they are open source nothing prevents you from creating different versions of that app (which are called forks).

as you say:

You should have write access to your fork

Agree, and I think I should not have write access to others fork by default .
The question is : I am not talking about my fork. I am talking about I can open a pr use stranger’s fork when I don’t have write access to his fork.

Maybe I didn’t describe clearly. The situation is :
1、There is a repo A , I’m not a menber of it , so I only have read access
2、I didn‘t fork repo A
3、There is someone else forked repo A, his fork repo is repo B . Also, I don’t have write access to B.

My question is, I don’t have any modify access to A and B . But github now allow me to open a pull reuest form B to A . Is it nromal to you? I would like to know you opinion.

1 Like

This seems strange indeed, you should only be able to create a PR from a repo to which you own or are a collaborator of, as far as I know — otherwise, you would be making PRs on other people’s behalf.

Do you have a practical example that you can link? I.e. a PR you managed to create from similar repos?

I confirm, I was able to get to the Create a pull request stage from https://github.com/PeterAlfredLee/commons-vfs to https://github.com/apache/commons-vfs, like in your screenshot — I didn’t actually submit the pull request, so I’m not sure if doing so would automatically create a fork of PeterAlfredLee’s commons-vfs repos to my account. Probably this is what would happen, although the pull request forms you land on seem quite the last stage of creating a PR.

You really got me curious on this, and I’d like to read a reply from some admins on this. I’m wondering:

  1. Is it really possible to create a PR from someone else’s account to the upstream or another fork of the same repo?
  2. If so, under whose account the PR appear in the final squash/merge?