在VS Code中t把分支写的代码合并到master中并提交到远程仓库github上

新建分支dxj,然后把分支dxj写的代码合并到master中并push到远程仓库github中,步骤如下:

1.在当前主分支master中新建分支dxj

E:\projects\ERP\zyyerp-front>git branch dxj

2.在master中切换到分支dxj

E:\projects\ERP\zyyerp-front>git checkout dxj 
Switched to branch 'dxj'
Your branch is up to date with 'origin/dxj'.

3.查看当前分支,命令:git branch 。带有星号的就是当前使用的分支。然后dxj编写自己负责的代码。

E:\projects\ERP\zyyerp-front>git branch
* dxj
  master

4.添加所有修改代码至暂存区(local cache),命令git add -A

E:\projects\ERP\zyyerp-front>git add -A

5.快捷提交至本地仓库(local repository) ,命令:git commit -am ‘这里是这次提交写的评论’

E:\projects\ERP\zyyerp-front>git commit -am '开始主页布局'
[dxj 088e3e9] '开始主页布局'
 1 file changed, 23 insertions(+), 3 deletions(-)

6.把分支dxj合并到master之前先要切换分支到mster,切换分支命令:git checkout branchName

E:\projects\ERP\zyyerp-front>git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.

查看是否切换成功

E:\projects\ERP\zyyerp-front>git branch
  dxj
* master

7.把分支dxj写的代码合并到master中,命令:git merge mergeTarget

E:\projects\ERP\zyyerp-front>git merge dxj
Updating 3c89c9d..088e3e9
Fast-forward
 src/components/Home.vue | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

8.主分支master最新代码推送到远程仓库(remote git repository) ,命令:git push

E:\projects\ERP\zyyerp-front>git push
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 902 bytes | 902.00 KiB/s, done.
Total 5 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/cn-hyf/zyyerp-front.git
   3c89c9d..088e3e9  master -> master

9.查看树状态,nothing to commit, working tree clean表示当前修改的代码都同步到远程仓库了。

E:\projects\ERP\zyyerp-front>git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

10.上面的步骤已经把分支dxj写的代码合并到master中了,同时也把master最新代码推送到远程仓库了。最后也要把子分支dxj也推送到远程仓库。
10.1 切换到dxj分支,命令git checkout dxj

E:\projects\ERP\zyyerp-front>git checkout dxj
Switched to branch 'dxj'

10.2 把分支dxj写的代码推送到远程仓库github中,命令git push -u origin dxj

E:\projects\ERP\zyyerp-front>git push -u origin dxj 
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'dxj' on GitHub by visiting:
remote:      https://github.com/cn-hyf/zyyerp-front/pull/new/dxj
remote:
To https://github.com/cn-hyf/zyyerp-front.git
 * [new branch]      dxj -> dxj
Branch 'dxj' set up to track remote branch 'dxj' from 'origin'.

10.3 查看树状态

E:\projects\ERP\zyyerp-front>git status
On branch dxj
Your branch is up to date with 'origin/dxj'.

nothing to commit, working tree clean
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值