git push git@github.com:remoteUser/remoteRepo localBranch:remoteBranch
The normal git push
command usually looks like this:
git push origin branch
Pushing to another developer’s branch follows a similar pattern: origin
is the other person’s repo, and branch
maps your local branch to the same branch on their remote repo.
origin
= git@github.com:remoteUser/remoteRepo
branch
= localBranch:remoteBranch
Breaking down each variable:
remoteUser
refers to the username of the developer who made the pr on your repo
remoteRepo
refers to the name of the repo that the other developer is creating the PR from, usually, this is the same name as your repo.
localBranch
refers to the branch name of your local copy of their remote branch
remoteBranch
refers to the branch name of that their PR is originating from on their remoteRepo
Keep in mind, that you can only push to PRs from other developers on your repo if that developer selected “Allow edits from maintainers” when they created their PR.
Let’s say you created the open source project, Material Bread. After releasing the project, another developer, with the Github username alburdette619, forks your project and creates a pull request with some new features. While reviewing alburdette619
’s PR you realize that his changes will need to be documented in the project’s README.
First, we need to fetch his changes into a branch on our local machine. We can do that using this command:
git fetch origin pull/branch/head:branchName
In this case, the branch on his PR is number 306
, and I want to name it pr/306
:
git fetch origin pull/306/head:pr/306
We can now make changes on our local branch pr/306
and commit them:
git commit -m "Update Readme with feature xyz"
Finally, we can push these changes to alburdette619
’s PR with the new commit using the command defined at the top of the article.
git push git@github.com:remoteUser/remoteRepo localBranch:remoteBranch
The remoteUser
is alburdette619
, the remoteRepo
is material-bread
, the localBranch
is pr/306
, and the remoteBranch
is 306
.
git push git@github.com:alburdette619/material-bread pr/306:306
(备注: 转载自网络)
声明:本站是个人开设维护的网站,主要用于收集网络美文、技术文章与原创生活记录等,系孤芳自赏、个人用途,内容如有侵权请联系站长删除。