问题
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?
回答1:
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.
回答2:
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".
回答3:
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?
回答4:
Pull Request: I Request to you to Pull mine.
回答5:
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.
回答6:
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.
回答7:
I think its a silly terminology because I want to think that I want to PUSH something to you and not thinking vice versa asking someone else to pull mine addings. Therefore it should be changed into PUSH REQ. since I'm the active part. The arrow goes the other way starting with me and not the Goofy in the other end. IMHO.
回答8:
To understand this better and remember it forever, you need to Picturize it.
Picture a big, living tree {as your repository}.
The tree is too sturdy for you to push a branch into in or add a new part into it {symbolises creating a new branch or you pushing code in it},
instead you must ask the tree to pull a branch into the trunk or have the changes from you.
The term “pull requests” comes from the distributed nature. Instead of just pushing your changes into the repository (like you would do with a centralized repository, e.g. with Subversion), you are publishing your changes separately and ask the maintainer to pull in your changes. The maintainer then can look over the changes and do said pull.
So you basically "request" the guys with writing access to repo you want to contribute, to "Pull" from you repo.
Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch. Github Explanation
These are mostly taken from other stack-overflow contributors but edited and merged to explain better for the question
回答9:
Think This way. There are two individuals. Local repository vs Remote repository.
- When you type Push from Local. (
git push
) - You throw your codes to the remote repository. in other words, the Remote repository is Pulling codes from you(Local).
You are requesting something. So, ask your self,
- Do you want Remote repository taking codes from you? - Pull Request.
来源:https://stackoverflow.com/questions/21657430/why-is-a-git-pull-request-not-called-a-push-request