Qiang Blog

Just another zhangjingqiang's blog.

How to use git subtree

Example

repository 1

app1

app1
|-app
|-submodule/app2

repository 2

app2
|-something

What to do

After change something in submodule/app2 in repository 1, push the change to repository 2, too.

Command

# Under repository 1
git subtree push --prefix submodule/app2 --squash https://github.com/your_account/your_repository.git your_branch

When to use

Such as rails engine

http://guides.rubyonrails.org/engines.html

git