目 录CONTENT

文章目录

Git flow工作流使用记录-建立新的功能分支

DevWiki
2017-07-18 / 0 评论 / 0 点赞 / 18 阅读 / 0 字 / 正在检测是否收录...
温馨提示:
本文最后更新于2024-03-31,若内容或图片失效,请留言反馈。 部分素材来自网络,若不小心影响到您的利益,请联系我们删除。
updated: 2017/07/18 16:48:45
status: publish
author: DevWiki
categories: 
  - 工具
tags: 
  - git
  - git flow

0x01.进入工作目录

cd  /c/Dev/Workspace/XTCWatch/gitlab/AndroidSuit

0x02.克隆项目代码

$ git clone git@172.28.10.23:AndroidSuit/WidgetCommon.git

Cloning into 'WidgetCommon'...
remote: Counting objects: 7074, done.
remote: Compressing objects: 100% (2435/2435), done.
remote: Total 7074 (delta 3358), reused 7074 (delta 3358)
Receiving objects: 100% (7074/7074), 30.06 MiB | 11.26 MiB/s, done.
Resolving deltas: 100% (3358/3358), done.
Checking connectivity... done.

0x03.转到代码目录查看branch

cd WidgetCommon
$ git branch

* develop

0x04.创建新功能分支

$ git branch feature/newFun  //创建新分支
$ git branch  //查看分支

* develop
  feature/newFun

$ git checkout feature/newFun  //切换分支
Switched to branch 'feature/newFun'

$ git branch
  develop
* feature/newFun

或者一步操作:

$ git checkout -b feature/newFun
Switched to a new branch 'feature/newFun'

$ git branch
  develop
* feature/newFun

0x05.开发新功能提交代码(首次push和非首次push)

1.新建readme文件并提交

//添加修改文件
$ git add readme.md

//提交到本地缓冲区
$ git commit -m "添加Readme文件"

[feature/newFun 2e422bb] 添加Readme文件
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.md

2.推送到远程

第一次推送到远程分支需要设置上游分支

//推送到远程分支
$ git push

fatal: The current branch feature/newFun has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin feature/newFun


//设置上游分支并推送
$ git push --set-upstream origin feature/newFun

Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 288 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote:
remote: To create a merge request for feature/newFun, visit:
remote:   http://172.28.10.23/AndroidSuit/WidgetCommon/merge_requests/new?merge_request%5Bsource_branch%5D=feature%2FnewFun
remote:
To git@172.28.10.23:AndroidSuit/WidgetCommon.git
 * [new branch]      feature/newFun -> feature/newFun
Branch feature/newFun set up to track remote branch feature/newFun from origin.

3.修改readme文件提交并推送到远程

//修改readme文件
$ git status

On branch feature/newFun
Your branch is up-to-date with 'origin/feature/newFun'.
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:   readme.md

no changes added to commit (use "git add" and/or "git commit -a")

//添加修改文件
$ git add readme.md

//提交到缓存区
$ git commit -m "修改readme"
[feature/newFun 18f3f72] 修改readme
 1 file changed, 1 insertion(+)

//推送到远程
$ git push
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 274 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote:
remote: To create a merge request for feature/newFun, visit:
remote:   http://172.28.10.23/AndroidSuit/WidgetCommon/merge_requests/new?merge_request%5Bsource_branch%5D=feature%2FnewFun
remote:
To git@172.28.10.23:AndroidSuit/WidgetCommon.git
   2e422bb..18f3f72  feature/newFun -> feature/newFun
0
git
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin
博主关闭了所有页面的评论