git分支管理规范和gitee上分支开发

git分支管理规范

  • 初始化仓库
    git init

  • 初始化master
    vim Readme.md
    git add .
    git commit -m "init"

  • 创建开发分支
    git branch develop
    git checkout develop

  • 开发一个功能
    vim dev1.txt
    git add .
    git commit -m "完成dev功能的开发"

  • 开发新特性1
    git branch feature-1
    git checkout feature-1
    vim feature1.txt
    git add .
    git commit -m "完成feature1功能的开发"

  • 开发新特性2
    git checkout develop(返回develop分支)
    git branch feature-2
    git checkout feature-2
    vim feature2.txt
    git add .
    git commit -m "完成feature2功能的开发"

  • 合并特性分支feature-1,feature-2
    git checkout develop
    git merge feature-1
    git merge feature-2
    ls

  • 删除feature分支
    git branch -d feature-1
    git branch -d feature-2
    git branch

  • 创建发布分支(测试)
    git branch release-v0.1
    git checkout release-v0.1

  • feature2.txt出现了bug
    vim feature2.txt
    git add .
    git commit -m "update"

  • 合并release-v0.1分支到develop(后续可继续开发新特性fearure-3)
    git checkout develop
    git merge release-v0.1

  • 合并release-v0.1到master(合并到主分支用于发布)
    git checkout master
    git merge release-v0.1

  • 删除release-v0.1分支
    git branch -d release-v0.1

  • 修复线上产品bug
    git checkout master
    git branch hotfix-1
    vim dev.txt
    git add .
    git commit -m "update"

  • 合并hotfix到master及develop
    git checkout master
    git merge hotfix-1
    git checkout develop
    git merge hotfix-1

  • 删除hotfix-1分支
    git branch -d hotfix-1

  • 在master分支上添加标签
    git tag -a v0.1.1


gitee上分支开发

  • 配置gitee
  1. 注册
  2. 配置本地git git config --global user.email "[email protected]"
  3. 配置本地git git config --global user.name "xxxx"
  4. 生成本地公钥:ssh-keygen
  5. 查看公钥信息 cat ~/.ssh/id_rsa.pub
  6. gitee上配置ssh公钥信息
  • 克隆远程仓库
    git clone 远程仓库地址

  • 创建分支
    git branch develop

  • 推送本地分支到远程
    git push origin develop:develop

  • 推送本地修改到远程仓库
    git push (一般推送前先git pull)

  • 下载远程分支
    git pull

  • 如果pull下载到本地没有develop分支的场景
    git checkout -b develop origin/develop

  • 提交tag标签
    git push --tags

  • 删除远程分支
    git push origin --delete develop

  • 删除本地已经关联的远程分支
    git branch -r -d origin/releasev0.1


  • 分支合并冲突实验
    git checkout develope
    git branch feature-1
    git branch feature-2
    git checkout feature-1
    vim dev.txt
    git add .
    git commit -m “update”
    git checkout feature-2
    vim dev.txt
    git add .
    git commit -m “update”
    git checkout develope
    git merge feature-1
    git merge feature-2
    vim dev.txt //解决冲突,删除多余信息
    git add .
    git commit -m “update”
    删除分支
    git branch -d feature-1
    git branch -d feature-2

谢谢!

猜你喜欢

转载自blog.csdn.net/qq_43371004/article/details/90116390