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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
Phase02_AI座学_応用
overflowinc
0
2.8k
AI時代のオンプレ-クラウドキャリアチェンジ考
yuu0w0yuu
0
230
Phase08_クイックウィン実装
overflowinc
0
1.7k
From Senior to Staff : To infinity and beyond !
kuahyeow
0
110
Phase04_ターミナル基礎
overflowinc
0
2.3k
【AWS】CloudTrail LakeとCloudWatch Logs Insightsの使い分け方針
tsurunosd
0
120
AIエージェント勉強会第3回 エージェンティックAIの時代がやってきた
ymiya55
0
120
Phase05_ClaudeCode入門
overflowinc
0
2.1k
Kubernetesの「隠れメモリ消費」によるNode共倒れと、Request適正化という処方箋
g0xu
0
120
The Rise of Browser Automation: AI-Powered Web Interaction in 2026
marcthompson_seo
0
310
Phase07_実務適用
overflowinc
0
1.9k
AIエージェント×GitHubで実現するQAナレッジの資産化と業務活用 / QA Knowledge as Assets with AI Agents & GitHub
tknw_hitsuji
0
230
Featured
See All Featured
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
330
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
How to Talk to Developers About Accessibility
jct
2
160
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
1.9k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.2k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
170
The browser strikes back
jonoalderson
0
840
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Code Review Best Practice
trishagee
74
20k
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