git命令--subtree
git命令--subtree
[TOC]
subtree 主要命令
git subtree add --prefix=<prefix> <commit>
git subtree add --prefix=<prefix> <repository> <ref>
git subtree pull --prefix=<prefix> <repository> <ref>
git subtree push --prefix=<prefix> <repository> <ref>
git subtree merge --prefix=<prefix> <commit>
git subtree split --prefix=<prefix> [OPTIONS] [<commit>]
项目地址
https://github.com/test/test_parent.git master
https://github.com/test/test_lib.git master
test_parent 文件结构
.
|--- .git
|--- testfile1
|--- testfile2
|--- sub
|--- subfile1
|--- subfile2
|--- lib
|--- libfile1
|--- libfile2
- 其中sub文件夹为subtree repo的目录
test_lib 文件结构
.
|--- .git
|--- subfile1
|--- subfile2
|--- lib
|--- libfile1
|--- libfile2
lib repo
lib仓库操作只要正常pull push 就可以 不受影响
parent repo
parent仓库下subtree操作如下
subtree add
parent添加test_lib到parent的sub目录
git subtree add --prefix=sub https://github.com/test/test_lib.git master --squash
(--squash参数表示不拉取历史信息,而只生成一条commit信息。)
subtree pull
parent的sub目录进行代码更新
git subtree pull --prefix=sub https://github.com/test/test_lib.git master --squash
从lib仓库拉取更新后,会在本地仓库自动生成commit信息,此时需要git push origin master , 这样普通parent仓库成员,才能正常拉取已经从lib仓库拉取得更新。
subtree push
git subtree push--prefix=sub https://github.com/test/test_lib.git master --squash
简化命令
使用remote建立子仓库,
git remote add -f lib https://github.com/test/test_lib.git
然后之前得三条subtree命令可以写成这样
git subtree add --prefix=sub lib master --squash
git subtree pull --prefix=sub lib master --squash
git subtree push --prefix=sub lib master
注:建立好子仓库后,简便了操作需要注意自己平时正常得pull操作已经push操作,主要是注意自己得pull和push得remote路径(有些人会直接使用git push或者TortriseGit直接pull或push得习惯),如果在parent直接正常push到lib仓库,一般情况会提醒你存在内容尚未pull下来,然后pull下来之后解决冲突或自动merge,此时如果继续push过去得就会将lib仓库完全替换为parent仓库
提示如下如果出现,请重新审查自己操作是否正确
Pushing to https://github.com/test/test_lib.git
To https://github.com/test/test_lib.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/test/test_lib.git
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git命令--subtree的更多相关文章
- 常look的Git命令
常用的Git命令 命令 简要说明 git add 添加至暂存区 git add–interactive 交互式添加 git apply 应用补丁 git am 应用邮件格式补丁 git a ...
- Git命令详解
一个中文git手册:http://progit.org/book/zh/ 原文:http://blog.csdn.net/sunboy_2050/article/details/7529841 前面两 ...
- Git 命令速查表
Git 命令速查表 1.常用的Git命令 命令 简要说明 git add 添加至暂存区 git add-interactive 交互式添加 git apply 应用补丁 git am 应用邮件格式补丁 ...
- Git命令速查表【转】
本文转载自:http://www.cnblogs.com/kenshinobiy/p/4543976.html 一. Git 常用命令速查 git branch 查看本地所有分支git status ...
- git 命令图解
git 命令图解 初始化版本库 git config user.name "lsgx" git config user.email "lsgxthink@163.co ...
- Git初探--笔记整理和Git命令详解
几个重要的概念 首先先明确几个概念: WorkPlace : 工作区 Index: 暂存区 Repository: 本地仓库/版本库 Remote: 远程仓库 当在Remote(如Github)上面c ...
- 工作中常用的git命令
一 常用Git命令 git clone:(区分SSH or HTTP) git init:初始化仓库 二 Git命令详解 Git Bash下,cd /c git clone,从远程Git版本库克隆一份 ...
- 常用 Git 命令清单
我每天使用 Git ,但是很多命令记不住. 一般来说,日常使用只要记住下图6个命令,就可以了.但是熟练使用,恐怕要记住60-100个命令. 下面是我整理的常用 Git 命令清单.几个专用名词的译名如下 ...
- ***Linux下使用git命令及github项目
在linux下搭建git环境1.创建Github账号,https://github.com2.Linux创建SSH密钥: ssh-keygen ##一直默认就可以了 3.将公钥加入到Github账户 ...
随机推荐
- 安装Office Visio 提示Office 16 Click-to-Run Extensibility Component
今天在安装 Office Visio 2016 时,点击安装程序,出现以下错误: 出现这个问题的原因就是你的电脑以前安装过32位的office,卸载时,注册表没有清理干净. 解决方案: 在win1 ...
- 教你制作挂件头像 | 小程序七十二变之 canvas 绘制国旗头像
昨天朋友圈被「请给我一面国旗@微信官方」刷屏,虽然知道是假的,但是从另一个角度来看,弄清楚如何实现更有趣. 1.canvas 这就不得不提到小程序中的 API canvas,H5 中也是有 canva ...
- SparkStreaming整合Flume的pull报错解决方案
先说下版本情况: Spark 2.4.3 Scala 2.11.12 Flume-1.6.0 Flume配置文件: simple-agent.sources = netcat-source simpl ...
- Python3程序设计指南:01 过程型程序设计快速入门
大家好,从本文开始将逐渐更新Python教程指南系列,为什么叫指南呢?因为本系列是参考<Python3程序设计指南>,也是作者的学习笔记,希望与读者共同学习. .py文件中的每个估计都是顺 ...
- e课表项目第二次冲刺周期第三天
昨天干了什么? 昨天和我们组的组员商量,确定了第二个界面的框架内容,即内容的输入和完成按钮,然后通过在网上搜索图片资源,然后我们利用ps软件,将图片通通设置了大小,进行了裁剪,最后为我们所利用,实现第 ...
- 从零学习基于Python的RobotFramework自动化
从零学习基于Python的RobotFramework自动化 一. Python基础 1) 版本差异 版本 编码 语法 其他 2.X ASCII try: raise Type ...
- Javascript之傻傻理不清的原型链、prototype、__proto__
新人学习Javascript,其中的原型链一直是云里雾里,不得要领,查了很多相关资料,觉得这遍讲得最为清晰易懂,特转载分享,共同学习. 1. JavaScript内置对象 所谓的内置对象 指的是:Ja ...
- php和apache的关系是什么?
例如我们在自己的电脑里练习如何做网站的时候,我们需要搭建一个本地环境,这个本地环境就是PHP+APACHE + MYSQL的环境,这样就可以让我们的电脑拥有PHP要求的运行环境了.那么php和apac ...
- 开源造轮子:一个简洁,高效,轻量级,酷炫的不要不要的canvas粒子运动插件库
一:开篇 哈哈哈,感谢标题党的莅临~ 虽然标题有点夸张的感觉,但实际上,插件库确实是简洁,高效,轻量级,酷炫酷炫的咯.废话不多说,先来看个标配例子吧: (codepen在线演示编辑:http://co ...
- 手绘风格的 JS 图表库:Chart.xkcd
本文作者:HelloGitHub-kalifun 图表库千万个今天 HelloGitHub 给大家推荐个很有"特色"的图表库:一个手绘风格的 JS 图表库 -- Chart.xkc ...