lq782655835/blogs

git团队规范

Opened this issue · 0 comments

总结团队git规范以及常用的git命令操作。Mac推荐可视化软件Sourcetree

git规范

  1. 一张图原理

image

  1. 分支规范
  • 核心分支

    • master
    • develop
  • 临时分支

    • feature
    • release
    • fix

临时分支建议隔段时间清理一下。建议分支命名:type + function + date, 如做了select组件特性,命名为feature-select-0812

image

  1. 提交规范

type: 功能简述 + 详情

type: feature、 enhance、 fix、 test、docs

命令式提交代码

  1. 提交到本地仓库
git add .
git commit -m 'i'
  1. 提交到远程仓库
git push origin master

本地项目关联远程仓库

  1. 前提:本地项目已存在 && 远程仓库已新建

  2. 本地仓库转为本地版本库

cd your-project
git init
git add .
git commit -m 'init'
  1. 关联远程仓库(important)
git remote add origin <URL>
  1. 推送远程仓库
  • 远程不冲突
git push -u origin master
  • 远程冲突

    1. 拉取远程仓库最新文件
    git pull origin master --allow-unrelated-histories
    1. 手动解决冲突,然后再重新本地提交,再推送远程提交。
    solve conflict
    git add .
    git commit -m 'conflict'
    git push -u origin master

打tag

git这个功能相当于,给项目做一个总结,存档当前代码。

查看tag

git tag

新建tag并推送

git tag -a <tag-name> -m <comment>
git push origin --tags