Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
git submodule && subtree
Search
Zhe Yu
April 01, 2014
Technology
0
100
git submodule && subtree
Zhe Yu
April 01, 2014
Tweet
Share
More Decks by Zhe Yu
See All by Zhe Yu
git submodule && git subtree
lazynight
0
290
Other Decks in Technology
See All in Technology
SREが向き合う大規模リアーキテクチャ 〜信頼性とアジリティの両立〜
zepprix
0
390
Claude_CodeでSEOを最適化する_AI_Ops_Community_Vol.2__マーケティングx_AIはここまで進化した.pdf
riku_423
2
420
モダンUIでフルサーバーレスなAIエージェントをAmplifyとCDKでサクッとデプロイしよう
minorun365
2
130
インフラエンジニア必見!Kubernetesを用いたクラウドネイティブ設計ポイント大全
daitak
0
320
(金融庁共催)第4回金融データ活用チャレンジ勉強会資料
takumimukaiyama
0
120
生成AI時代にこそ求められるSRE / SRE for Gen AI era
ymotongpoo
5
2.6k
Introduction to Bill One Development Engineer
sansan33
PRO
0
360
セキュリティ はじめの一歩
nikinusu
0
1.5k
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
180
日本の85%が使う公共SaaSは、どう育ったのか
taketakekaho
1
130
2026年、サーバーレスの現在地 -「制約と戦う技術」から「当たり前の実行基盤」へ- /serverless2026
slsops
2
210
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
10k
Featured
See All Featured
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Building the Perfect Custom Keyboard
takai
2
680
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
440
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
88
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
96
Odyssey Design
rkendrick25
PRO
1
490
Music & Morning Musume
bryan
47
7.1k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
117
110k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
350
Optimising Largest Contentful Paint
csswizardry
37
3.6k
Transcript
Git Subtree解说 by于哲 2014.3.31
场景 对于⼀一些⽐比较⼤大的⼯工程,为了便于复⽤用,常常需要抽取⼦子 项⺫⽬目 A B C
⽅方案1:git submodule ! ⽅方案2:git subtree
git submodule submodule项⺫⽬目和它的⽗父项⺫⽬目本质上是2个独⽴立的git仓库, 只是⽗父项⺫⽬目存储了它依赖的submodule项⺫⽬目的版本号信息⽽而已。 坑: • git pull之后,需要 git submodule
update • detached HEAD state,需要 git checkout master • git clone 之后,需要 git submodule init & update • messy,etc
git subtree 简介: 替代git submodule 命令,合并⼦子仓库到项⺫⽬目中并放在⼦子 ⺫⽬目录,管理、更新都更加⽅方便。 要求: git version
> 1.8.0.0 if git version < 1.8.0.0: go https://github.com/apenwarr/git-subtree
why git subtree? • 管理和更新流程⽐比较⽅方便 • git v1.5.2以后建议使⽤用git subtree (git
v1.8.0.0 才合并进来) • 仓库 clone下来不需要 init 和 update • 不会产⽣生像.gitmodule类似的⽂文件 • git submodule 删除起来⽐比较费劲 • 另外还有⼀一些团队协作时的尴尬问题
如何使⽤用git subtree? 前期准备: ! 创建本地项⺫⽬目(两个项⺫⽬目,⼀一个库): git --git-dir=proj1.git init --bare git
--git-dir=proj2.git init —bare git --git-dir=lib1.git init —bare ! ! 填充数据,提交,etc
如何使⽤用git subtree? ! ! 1. git remote add -f <⼦子仓库名>
<⼦子仓库地址> ! 其中-f意思是在添加远程仓库之后,⽴立即执⾏行fetch ! 2. git subtree add --prefix=<⼦子⺫⽬目录名> <⼦子仓库名> <分⽀支> —squash ! —squash意思是把subtree的改动合并成⼀一次commit,这样就不⽤用拉取⼦子 项⺫⽬目完整的历史记录。 ! --prefix之后的=等号也可以⽤用空格。 ! ! 添加⼦子⺫⽬目录,建⽴立与git项⺫⽬目的关联
如何使⽤用git subtree? ! ! 1. git fetch <远程仓库名> <分⽀支> !
2. git subtree pull --prefix=<⼦子⺫⽬目录名> <远程分⽀支> <分 ⽀支> --squash ! ! ! 从远程仓库更新⼦子⺫⽬目录
如何使⽤用git subtree? ! ! 1. git subtree push --prefix=<⼦子⺫⽬目录名> <远程分⽀支名>
分⽀支 ! ! ! ! ! 从⼦子⺫⽬目录push到远程仓库
参考 • http://aoxuis.me/posts/2013/08/07/git-subtree/ • http://blogs.atlassian.com/2013/05/alternatives-to-git- submodule-git-subtree/
THANK YOU @jackyu