The terminology used to merge a branch with an official repository is a 'pull request'. This is confusing, as it appears that I am requesting to push my changes to the official repository.
Why is it called a pull request and not a push request?
If you have a code change in your repository, and want to move it to a target repository, then:
- "Push" is you forcing the changes being present in the target repository (
git push
). - "Pull" is the target repository grabbing your changes to be present there (
git pull
from the other repo).
A "pull request" is you requesting the target repository to please grab your changes.
A "push request" would be the target repository requesting you to push your changes.
When you send a pull request, you're asking (requesting) the official repo owner to pull some changes from your own repo. Hence "pull request".
tl;dr since I am not allowed to make a push, I'll just nicely make a request to the repo owner so they decide to pull
Who can push code to a repository?
Should anyone (possibly evil or uneducated or unknown) be able to come and say here I just pushed this to your master branch and messed up all your code HAHAHA! ?
Surely you don't want him to do that. By default a safety net is set so no one can push to your repo. You can set others as a collaborator, then they can push. You would give such access to people you trust.
So if you're not a collaborator and try to push, you will get some error indicating you don't have permission.
So how can other developers push to a repo they are not given permission to push?
You can't give access to everyone, yet you want to give others an outlet/entry point so they can make 'a request to the repo owner to pull this code into the repo'. Simply put by making the repo accessible, they can fork it...make their changes in their own fork. Push their changes to their own fork. Once it's in their in their own remote repo:
They make a pull request from their fork and the owner of the upstream repo (which you can't push directly to) will decide whether or not to merge the pull request.
Also a semi-related question I recommend reading What exactly happens in a git push? Why isn't a git push considered just like a git merge?
Pull Request: I Request to you to Pull mine.
It's the word "Request" that is key in these actions. You could also think of it as saying "I have a request for you to take my work, do you accept?" - "A Pull Request".
It's slightly confusing at first, but makes sense eventually.
I want to push something to someone else's repo.
I do not have the permission to push (or pull, for that matter).
The owner/collaborators has permissions. They can pull as well as push. I cannot push.
So, I request them to perform a pull from me - which indirectly means that I am requesting them to accept my push.
So, no request for push. Only for a pull. And for acceptance of a push.
Hence, a 'pull' request. And not a 'push' request.
来源:https://stackoverflow.com/questions/21657430/why-is-a-git-pull-request-not-called-a-push-request