'How can I clone git branch with submodule?

I have a branch called A (not main branch) and there's some files and one submodule. I want to clone this submodule to my local repository but I don't know how to.

I tried some commands but they only cloned files and folders. They only copy the folder of the submodule, except the files and folders inside it.

Here are some commands I tried but they didn't work.

git clone --recurse-submodules -b week3 --single-branch git://github.com/foo/bar.git
git clone -b week3 --single-branch git://github.com/foo/bar.git

How can I clone a submodule in a specific branch(not main) to my local computer?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source