美文网首页
Git subtree组件库的使用

Git subtree组件库的使用

作者: 云醉倚清风 | 来源:发表于2022-11-15 11:03 被阅读0次

一:如何把已有的公共部分变为组件库

1:把公共部分在ide中拖入一个文件中

目的:使用ide的能力让引用文件自动变更引用位置

由此:
├── components
│   ├── Banner
│   ├── ComponentA.vue
│   ├── ComponentB.vue
│   ├── ComponentC.vue
│   ├── Filter
│   └── Loading
├── utlis
└── views

变为:
├── components
│   ├── Banner
│   ├── Common
│   │   ├── ComponentA.vue
│   │   ├── ComponentB.vue
│   │   └── ComponentC.vue
│   ├── Filter
│   └── Loading
├── utlis
└── views

2:将这个目录的文件copy到外面

目的:保存组件库文件
保存:ComponentA.vue ComponentB.vue ComponentC.vue

3:删除此目录

目的:后续会使用git命令重新增加

├── components
│   ├── Banner
│   ├── Filter
│   └── Loading
├── utlis
└── views

4:提交

目的:不提交添加git在仓库会报错:Working tree has modifications. Cannot add.

5:自己在git仓库创建一个库

目的:保存组件库的远程仓库

6:项目中添加子仓库

git remote add -f <仓库别名> <仓库地址>
例子:git remote add -f common git@gitee.com:xxx/web-components.git

别名目的:为了后续不在写仓库的全部地址,只需要记住组件库远程地址的别名即可

7:项目中添加在仓库关联

git subtree add --prefix=<本地文件地址> <仓库地址> <仓库分支>
例子:git subtree add --prefix=Common common master
等于例子:git subtree add --prefix=Common git@gitee.com:xxx/web-components.git master
  • 本地文件地址:本地对应项目放置子仓库的位置,如果是多级 src/xx/Common
  • 仓库地址:远程仓库地址 可用上面第六步的地址别名
  • 仓库分支:远程仓库选择的分支
├── components
│   ├── Banner
│   ├── Common
│   ├── Filter
│   └── Loading
├── utlis
└── views

8:组件库文件拖入git生成的Common文件中

目的:子仓库添加组件库文件

9:拉取子仓库的远程仓库

git subtree pull --prefix=Common common master --squash

--squash 只生成一条commit记录...意思不让分支上的所有提交记录信息合并过来

10:推送子仓库更改

git subtree push --prefix=Common common master

二:使用已添加好的组件库的仓库

clone好后组件库就已添加完毕,后续只需要使用

git subtree pull --prefix=Common common master --squash
git subtree push --prefix=Common common master

可以查看git对应的配置文件

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
    ignorecase = true
    precomposeunicode = true
[remote "origin"]
    url = git@gitee.com:leadj/manager-web.git
    fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
    remote = origin
    merge = refs/heads/master
[remote "common"]
    url = git@gitee.xxxxx/web-components.git
    fetch = +refs/heads/*:refs/remotes/src/components/Common/*

子仓库的远程仓库是由git remote add -f命令生成的

相关文章

  • git subtree 的命令和使用说明

    git subtree add --prefix= git subtree add --...

  • Git Subtree的使用

    背景 项目A与项目B存在公用模块,在项目A中修改Bug或增加新功能需要同步到项目B中,由于存在区别所以还不能完全c...

  • git subtree 的使用

    参考:Git Tools - Subtree MergingThe power of Git subtreegit...

  • 版本库之间的依赖

    Git submodule和Git subtree 与子模块之间的依赖 对于子模块来说,其模块版本库可以被嵌入到主...

  • iOS-组件化开发- 本地私有库

    1. 创建本地私有库 创建需要做成组件的库1.png 使用git管理git initgit add .git co...

  • git subtree

    git subtree 1.在A项目中添加一个远程连接如下: 2.使用subtree命令添加需要依赖的远程仓库 3...

  • 组件化(第一篇)

    组件化 git 常用操作指令 cocoapods的基本使用 cocoapods本地私有库 一、git 常用操作指令...

  • 组件化总结

    一.git的使用 二、CocoaPods的使用 使用框架者 发布框架者 三、CocoaPods私有库 四、组件化实...

  • git merge two repos

    git clone git_linkFirstly add subtree, from which you wan...

  • Git依赖subtree

    Git依赖——subtree  与submodule相比,subtree的优势在于主项目与子模块的双向 通信,即主...

网友评论

      本文标题:Git subtree组件库的使用

      本文链接:https://www.haomeiwen.com/subject/puisxdtx.html