GitHub PR的一波骚操作,你Get到了么?

GitHub PR的一波骚操作

 

 

1.fork

从远端仓库https://github.com/apache/incubator-dolphinscheduler.git fork一份代码到自己的仓库中

2.clone

把自己仓库clone到本地

λ git clone https://github.com/xx/incubator-dolphinscheduler.git
Cloning into 'incubator-dolphinscheduler'...
remote: Enumerating objects: 304, done.
remote: Counting objects: 100% (304/304), done.
remote: Compressing objects: 100% (200/200), done.
Receiving objects: 100% (54821/54821), 152 (delta 38), pack-reused 54517 eceiving objects: 100% (54821/54821), 77.07 MiB | 918.00 KiB/s
 77.08 MiB | 463.00 KiB/s, done.
Resolving deltas: 100% (23530/23530), done.
Updating files: 100% (1557/1557), done.

3.remote

添加远端仓库地址,命名为upstream

git remote add upstream https://github.com/apache/incubator-dolphinscheduler.git

查看仓库

λ git remote -v
origin  https://github.com/xx/incubator-dolphinscheduler.git (fetch)
origin  https://github.com/xx/incubator-dolphinscheduler.git (push)
upstream        https://github.com/apache/incubator-dolphinscheduler.git (fetch)
upstream        https://github.com/apache/incubator-dolphinscheduler.git (push)

 

此时会有两个仓库:origin(自己的仓库)和upstream(远端仓库)

4.branch

查看分支

λ git branch -v
  dev                         d70d8a60 [Feature-3222][datasource] Store password in ciphertext instead  (#3330)

创建分支

λ git checkout -b dev-local
Switched to a new branch 'dev-local'
​
  • dev-local 用于本地测试、开发

在提交PR之前,需要创建一个分支专门用作此次PR代码分支,等待合并到原远端仓库后,可删除分支。

git checkout dev

dev-imp-server-ProcessUtils-temp 用于解决代码冲突

dev-imp-server-ProcessUtils 用于提交PR 的代码分支

 

D:\developer\git-repository\incubator-dolphinscheduler (dev-imp-server-ProcessUtils)
λ git add .
​
D:\developer\git-repository\incubator-dolphinscheduler (dev-imp-server-ProcessUtils)
λ git commit -m "server model ProcessUtils.java code cleaning." .
[dev-imp-server-ProcessUtils 69ba65db] server model ProcessUtils.java code cleaning.
 1 file changed, 6 insertions(+), 16 deletions(-)
​
D:\developer\git-repository\incubator-dolphinscheduler (dev-imp-server-ProcessUtils)
λ git push origin dev-imp-server-ProcessUtils
​

5.pull request

登录github.com 在自己仓库下,如果有更改的分支,系统会有提示栏,也可以通过点击 Pull request栏new pull request.

                                 GitHub PR的一波骚操作,你Get到了么?

 

                                   GitHub PR的一波骚操作,你Get到了么?

 

 

需要填写对本次RR的一个描述,目的,变更日志等。在网页下面也可以看见本次PR提交的代码变更。本次实例只是做了一些代码清理,清理不在引用的变量和清理不需要上抛的异常类型。

                                          GitHub PR的一波骚操作,你Get到了么?

 

                                           GitHub PR的一波骚操作,你Get到了么?

 

                                          GitHub PR的一波骚操作,你Get到了么?

 

 

 

 

提交之后,接着社区Committer们会做CodeReview,然后他会与您讨论一些细节(包括设计,实现,性能等)。当团队中所有人员对本次修改满意后,会将提交合并到dev分支

 

6.问题

如何保持和原远端仓库同步

获取/更新远端仓库代码

git fetch upstream

From https://github.com/apache/incubator-dolphinscheduler
 * [new branch]        1.2.0-release       -> upstream/1.2.0-release
 * [new branch]        1.2.1-release       -> upstream/1.2.1-release
 * [new branch]        1.3.1-release       -> upstream/1.3.1-release
 * [new branch]        1.3.2-release       -> upstream/1.3.2-release
 * [new branch]        alert_plugin_design -> upstream/alert_plugin_design
 * [new branch]        bcai-upgrade-java-version-for-sonarcloud -> upstream/bcai-upgrade-java-version-for-sonarcloud
 * [new branch]        dev                 -> upstream/dev
 * [new branch]        dev-1.3.0           -> upstream/dev-1.3.0
 * [new branch]        master              -> upstream/master
 * [new branch]        proposal            -> upstream/proposal
​

切换到dev分支 git checkout dev 同步远端仓库dev分支代码到本地仓库dev分支 git merge upstream/dev

提交到自己仓库 git push origin dev

                                                                 GitHub PR的一波骚操作,你Get到了么?

 

                                                                       长按,扫码,关注

                                                                      及时收看更多精彩内容

                                                GitHub PR的一波骚操作,你Get到了么?