---
title: "git submodule"
author: "夜鸣猪"
date: "2013-02-14T23:54:44Z"
tags: []
categories: ["编程语言"]
slug: "git-submodule"
draft: false
lastmod: "2013-02-16T00:14:17Z"
id: 1798128
url: "https://hlee.iteye.com/blog/1798128"
---

```ruby
# get the submodule initially
git submodule add ssh://bla submodule_dir
git submodule init
#git submodule update

# time passes, submodule upstream is updated
# and you now want to update

# change to the submodule directory
cd submodule_dir

# checkout desired branch
git checkout master

# update
git pull

# get back to your project root
cd ..

# now the submodules are in the state you want, so
git commit -am "Pulled down update to submodule_dir"


git submodules update --init

git submodule foreach git pull origin master

```



https://git.wiki.kernel.org/index.php/GitSubmoduleTutorial

http://git-scm.com/book/en/Git-Tools-Submodules