===============================================
Github从release-pp fixed bug过程
=============================================
建立空文件夹Exchange-API-Services-release_pp并进入
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi
$ mkdir Exchange-API-Services-release_pp
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi
$ cd Exchange-API-Services-release_pp
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp
$ dir
从远程clone仓库到本地
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp
$ git clone https://github.com/iht-dev/Exchange-API-Services.git
Cloning into 'Exchange-API-Services'...
remote: Enumerating objects: 592, done.
remote: Counting objects: 100% (592/592), done.
remote: Compressing objects: 100% (423/423), done.
remote: Total 11757 (delta 289), reused 368 (delta 80), pack-reused 11165
Receiving objects: 100% (11757/11757), 1.92 MiB | 1.65 MiB/s, done.
Resolving deltas: 100% (6481/6481), done.
dir查看目录中多了一个Exchange-API-Services文件夹,说明已经成功的从github克隆了到了本地。
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp
$ dir
Exchange-API-Services
执行cd进入到Exchange-API-Services目录中
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp
$ cd Exchange-API-Services/
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (master)
$
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp2/Exchange-API-Services (master)
$ dir
mvnw mvnw.cmd pom.xml README.md sql src 【这是maser分支的文件】
用资源管理器查看Exchange-API-Services 文件夹属性
大小 3.08 MB (3,237,155 字节)
占用:3.56 MB (3,735,552 字节)
包含:301 个文件,84 个文件夹
2018年12月26日,14:01:10
从上面可见,已经在(master)分支中。
特别提醒:我们从github上clone下来的代码默认是master分支代码。如果需要release_pp代码,我们需要把远程github上release_pp分支的代码checkout到本地。
直接用下面命令git checkout release_pp,就能达到上面的目的,并在本地自动建立。
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (master)
$ git checkout release_pp
Switched to a new branch 'release_pp' 【切换到一个[新]分支release_pp】
Branch 'release_pp' set up to track remote branch 'release_pp' from 'origin'.
【分支'release_pp'设置为从'origin'跟踪远程分支'release_pp'】
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp2/Exchange-API-Services (master)
$ ll
total 25
-rwxr-xr-x 1 yangj_000 197615 6693 12月 26 14:01 mvnw*
-rw-r--r-- 1 yangj_000 197615 5137 12月 26 14:01 mvnw.cmd
-rw-r--r-- 1 yangj_000 197615 4993 12月 26 14:01 pom.xml
-rw-r--r-- 1 yangj_000 197615 48 12月 26 14:01 README.md
drwxr-xr-x 1 yangj_000 197615 0 12月 26 14:01 sql/
drwxr-xr-x 1 yangj_000 197615 0 12月 26 14:01 src/
用资源管理器查看Exchange-API-Services 文件夹属性
大小: 3.72 MB (3,903,552 字节)
占用:4.38 MB (4,595,712 字节)
包含: 432 个文件,103 个文件夹
2018年12月26日,14:01:10
下面,在release_pp分支上建立自己的hotfix-xxx分支。
执行命令:git checkout -b hotfix-ETH-confirm_release_pp
远程和本地都没有hotfix-ETH-confirm_release_pp分支,所以用-b参数创建。如果直接执行:git checkout hotfix-ETH-confirm_release_pp会出错的,如下:
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp2/Exchange-API-Services (release_pp)
$ git checkout hotfix-ETH-confirm_release_pp
error: pathspec 'hotfix-ETH-confirm_release_pp' did not match any file(s) known to git
所以,必须用-b参数:git checkout -b hotfix-ETH-confirm_release_pp
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (release_pp)
$ git checkout -b hotfix-ETH-confirm_release_pp
Switched to a new branch 'hotfix-ETH-confirm_release_pp' [这里新分支,是指在本地]
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp2/Exchange-API-Services (hotfix-ETH-confirm_release_pp)
$
在本地新分支中hotfix-ETH-confirm_release_pp修改代码。
ok,至此在本地hotfix-ETH-confirm_release_pp分支中就可以开fixbug了。打开Eclipse开始码砖~修改WalletScheduleService.java文件。
修复bug后:
查看用命令git status状态,发现有个文件WalletScheduleService.java修改了:
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (hotfix-ETH-confirm_release_pp)
$ git status
On branch hotfix-ETH-confirm_release_pp
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: src/main/java/com/exchange/service/WalletScheduleService.java
no changes added to commit (use "git add" and/or "git commit -a")
需要先commit
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (hotfix-ETH-confirm_release_pp1226a)
$ git commit -am 'fixed'
[hotfix-ETH-confirm_release_pp1226a 939579a] fixed
1 file changed, 7 insertions(+), 7 deletions(-)
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (hotfix-ETH-confirm_release_pp1226a)
push到github新建一个分支,在github发起pull-request合并到release_pp。在本地release_pp分支就可以git pull了。
我们需要的是执行下面命令,将本次的fixed推到服务器新建分支hotfix-ETH-release_pp1226a (此分支在push时会在github自动创建)
命令:git push origin 本地分支名:远程分支名
$ git push origin hotfix-ETH-confirm_release_pp:hotfix-ETH-release_pp1226a
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (hotfix-ETH-confirm_release_pp)
$ git push origin hotfix-ETH-confirm_release_pp:hotfix-ETH-release_pp1226a
Enumerating objects: 17, done.
Counting objects: 100% (17/17), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 933 bytes | 311.00 KiB/s, done.
Total 9 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 4 local objects.
remote:
remote: Create a pull request for 'hotfix-ETH-release_pp1226a' on GitHub by visiting:
remote: https://github.com/iht-dev/Exchange-API-Services/pull/new/hotfix-ETH-release_pp1226a
remote:
To https://github.com/iht-dev/Exchange-API-Services.git
* [new branch] hotfix-ETH-confirm_release_pp -> hotfix-ETH-release_pp1226a
大工告成!
剩下的工作:登陆github.com。在github发起pull-request合并到release_pp。
pull-request时,注意方向:release_pp<---hotfix-ETH-release_pp1226a (pull request)
意思是:从hotfix-ETH-release_pp1226a向release_pp发起一个pull请求,请求release_pp从hotfix-ETH-release_pp1226a分支pull一次代码并merge.
需要release_pp的有权限的人view一下然后merge.
上面完成后,就可以在github上delete分支hotfix-ETH-release_pp1226a
在本地release_pp分支就可以git pull了。
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (release_pp)
$ git pull
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), done.
From https://github.com/iht-dev/Exchange-API-Services
30e8332..b3e740c release_pp -> origin/release_pp
Updating 30e8332..b3e740c
Fast-forward
.../java/com/exchange/service/WalletScheduleService.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
yangj_000@BOWEN MINGW64 /d/_ALD/CoreApi/Exchange-API-Services-release_pp/Exchange-API-Services (release_pp)
$
【重点命令】
$ git push origin hotfix-ETH-confirm_release_pp:hotfix-ETH-release_pp1226a
将本地 hotfix-ETH-confirm_release_pp分支推送到Github上并建立hotfix-ETH-release_pp1226a分支。以便pull request.
============================================
备用其他命令:
git branch --set-upstream 本地关联远程分支-
git branch --set-upstream-to=origin/remote_branch your_branch
其中,origin/remote_branch是你本地分支对应的远程分支;your_branch是你当前的本地分支。
网友评论