Search code examples
gitgit-submodules

need to switch to a different branch not listed in git submodule


I have a git submodule 'library' that I want to make changes to. The submodule currently tracks my 'develop' branch. I want the submodule to track a feature branch so the changes are associated with that branch.

I've tried going into the submodule folder and doing: git checkout feature and got error: pathspec 'feature' did not match any file(s) known to git.

When I ran git branch -a in the submodule folder I noticed my feature branch was not listed. I tried adding it by running git submodule add -b feature but that didn't work.

When I run git status in the submodule folder it says:

On branch develop
Your branch is up to date with 'origin/develop'

How do I switch the branch my git submodule is tracking?


Solution

  • to add a new branch named feature you need to first add it with this command:

    git checkout -b feature