Skip to content

Instantly share code, notes, and snippets.

@marc-hanheide
Created November 3, 2023 14:28
Show Gist options
  • Save marc-hanheide/77d2685ceb2aaa4b90324c520dd4c34c to your computer and use it in GitHub Desktop.
Save marc-hanheide/77d2685ceb2aaa4b90324c520dd4c34c to your computer and use it in GitHub Desktop.
Create a patch for submodules

How to create a patch for a repository with submodules

You checkout whatever repository you want.

Then you make all the changes that are required to make it all work in any submodule as needed. You don't commit in the submodules.

Make sure you have committed everything in your own repository and git diff shows that there are only changes in your submodules and you "parent" repository is still clean.

git --no-pager diff --no-color --submodule=diff > patch.diff

Then you can add patch.diff to you parent git repository which now contains all the changes

Apply the patch

Applying a patch is super easy for a new checkout:

  1. (you may have done this already): git clone --recurse-submodules
  2. applying the patch: patch -p < patch.diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment