Search code examples
githubgit-branchgit-submodules

How to pull changes from github submodule branch "A" into parent module branch "B"


I've made some changes in repository A, that are reflected in branch A. This repository A is a submodule for repository B. I want to reflect repository A's branch A changes in repository B's branch Y. How do I do this?


Solution

  • Let X be a branch of submodule A and Y be a branch of parent repository B.

    Switch to X and change directory to the root of B. Running git status would show something like this:

    On branch master
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git restore <file>..." to discard changes in working directory)
            modified:   A (new commits)
    
    no changes added to commit (use "git add" and/or "git commit -a")
    

    Then switch to Y and commit the changes:

    git switch Y
    git add A
    git commit