aermin / blog

📝 My blog / notes

Home Page:https://www.aermin.top/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何给别人的pr提交代码

aermin opened this issue · comments

比如aermin给XXX项目提了个pr,你review后觉得有要改的地方,通常是comment一下,让aermin自己改,还有一个方法就是你撸起袖子直接给这个pr提交修改的代码。

现在我们来讲讲给别人的pr提交代码的过程(本人自己尝试的方法且最终能挺好的work,有误请斧正)

正常的提pr,都会fork XXX项目,然后添加XXX项目为upstream,不知道怎么给比人提pr可以先看这个
所以这里你和aermin都fork了XXX 项目,然后你将fork后的项目clone到本地,然后在本地执行以下操作:

添加aermin的git url到你的remote

git remote add aermin-remote https://github.com/aermin/react-use.git

找到aermin-remote的目标branch,也就是aermin提pr的,你想改的那个pr的的分支

git branch -r

切到这个分支

git checkout aermin-remote /目标branch

基于此分支创建新的分支

git checkout -b your-new-branch

做一些你要的代码修改

write some new code

提交代码

git add --all

git commit -m 'test(googlechrome): skip very unstable case'

推到你的origin,--set-upstream() 对于每个最新的或成功推送的分支,添加上游(跟踪)引用,设置上游关联。

git push --set-upstream origin your-new-branch

--set-upstream 在git1.8.0 被废弃并替换成 --set-upstream-to: see [git1.8.0-rc1 announce](http://git.661346.n2.nabble.com/ANNOUNCE-Git-v1-8-0-rc1-tc7568792.html)

然后去aermin 的repo 提mr(选择your branch 和target branch,点击提交)

然后点击merge,完成。

当然给别人的pr提交代码应该还可以通过直接fork aermin/XXX项目,直接跳过几步从 git checkout -b your-new-branch 这一步开始,可以去试一试。

那个pr的原主这时可以把被人push的代码pull下来看看

git pull origin 目标branch

如果急着合并进自己的主分支,可以这样子:安装GitHub CLI。
image