有人在我的Github仓库上创建了拉取请求.它看起来很好看,但我不得不做一些小改动让它通过我的持续集成服务器.
Github的屏幕上"审查"请求的说明是:
git checkout -b otheruser-fix_somebug
git pull https://github.com/otheruser/myrepo.git fix_somebug
Run Code Online (Sandbox Code Playgroud)
然后我做了我的更改,并在本地提交.然而,当我去跑步时git push,git告诉我:
fatal: The current branch otheruser-fix_somebug has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin otheruser-fix_somebug
Run Code Online (Sandbox Code Playgroud)
我做了,但我的更改没有在pull请求下显示,而是otheruser-fix_somebug在我的Github repo镜像的镜像副本下,并且未连接到pull请求.
我该如何调用git push以使更改出现在pull请求中?
第 1 步:在本地存储库中添加新的remote指向贡献者的指向
git remote add contributor https://github.com/contributor/repo.git
Run Code Online (Sandbox Code Playgroud)
您现在将拥有两个遥控器 -origin和conritbutor。要验证 - 运行以下命令:git remote -v
第 2 步:从新的远程获取
git fetch contributor
Run Code Online (Sandbox Code Playgroud)
第 3 步:根据更改创建一个新分支
git checkout -b contributor-main contributor/main
Run Code Online (Sandbox Code Playgroud)
(如果需要,将“main”替换为“master”)
第 4 步:进行更改、提交并推送
git push contributor contributor-main:main
Run Code Online (Sandbox Code Playgroud)
如果贡献者在创建 PR 时“允许维护者进行更改”(大多数情况下都是默认选项),则新提交将立即显示在 PR 中
PS 将“贡献者”替换为用户名
据我所知,只有在他们允许的情况下才能这样做.在过去,只有他们可以添加你作为他们的分支的贡献者,但是,在2016年9月,GitHub为这个用例添加了一个功能,允许请求Pull请求的人给予维护者许可.上传存储库只需标记一个复选框即可.
你可以对Pull Request做一个评论,告诉他们在合并Pull Request之前你想解决它们的一些问题,并声明你希望他们通过检查来授予你提交他们的Pull Request分支的权限. Pull Request上的"允许来自维护者的编辑"复选框,并为他们提供有关该功能的GitHub帮助页面的链接,以便他们可以确切了解如何启用它.完成后,您可以直接推送到其存储库的Pull Request分支.
如果他们没有/不会给你拉取请求分支的写入权限,你可以做的事情:
对他们的Pull请求发表评论:
对Pull Request中的代码进行注释:
按原样接受它,然后将其修复到您自己的存储库中
从拉取请求中检查分支怎么样?然后你可以在那里进行提交,并直接推送到该分支。
git fetch
git checkout fix_somebug
Run Code Online (Sandbox Code Playgroud)
添加包含您的更改的提交
git push origin fix_somebug
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3722 次 |
| 最近记录: |