Skip to content

Instantly share code, notes, and snippets.

@Cepr0
Created January 29, 2019 12:27
Show Gist options
  • Save Cepr0/0a84432f6d16f15560ffc425a22504cb to your computer and use it in GitHub Desktop.
Save Cepr0/0a84432f6d16f15560ffc425a22504cb to your computer and use it in GitHub Desktop.
Working with git submodules

Add submodule to the project

  1. Create subdir for submodule in the project dir
  2. Add necessary files to submodule dir
  3. In the submodule dir type the commands:
git init 
git add . 
git commit -m "Initial commit"
  1. Back to project dir
  2. Type the commands
git submodule add ../../<project dir>/<submodule dir>.git <submodule dir>
git add . 
git commit -m "Add submodule"

Clone project with submodules

git clone <project url>
git submodule update --init --recursive

Remove submodule from the project

git submodule deinit <submodule dir>
git rm <submodule dir>
git commit -m "Remove submodule"
rm -rf .git/modules/<submodule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment