Skip to content

Instantly share code, notes, and snippets.

@nst
Created May 3, 2016 08:34
Show Gist options
  • Save nst/df99f00154ae59794be3dc7054a0f651 to your computer and use it in GitHub Desktop.
Save nst/df99f00154ae59794be3dc7054a0f651 to your computer and use it in GitHub Desktop.
use git submodules
__Add Submodule__
git submodule add https://github.com/username/Module
┌─────────────────────────┐
│ MyProject │
│ ┌────────────────┐ │
│ │ Module │ │
│ └────────────────┘ │
└─────────────────────────┘
---
__Clone Project__
git clone https://github.com/username/MyProject
┌─────────────────────────┐
│ MyProject │
│ ┌ ─ ─ ─ ─ ─ ─ ─ ─ │
│ Module │ │
│ └ ─ ─ ─ ─ ─ ─ ─ ─ │
└─────────────────────────┘
__Update Submodule__
git submodule update --init
┌─────────────────────────┐
│ MyProject │
│ ┌────────────────┐ │
│ │ Module │ │
│ └────────────────┘ │
└─────────────────────────┘
---
__Update Submodule to Latest Version__
git submodule foreach git pull origin master
git commit -m "use latest version of module xxx"
┌─────────────────────────┐
│ MyProject │
│ ┌────────────────┐ │
│ │ Module │ │
│ │ latest version │ │
│ └────────────────┘ │
└─────────────────────────┘
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment