This repository is to test submodules. There are two submodule used in this example: feature1, and feature2. Both have includes are imported into the main file and defines are printed out to show that they're being used.
A caveat of this setup is that both feature modules are branches in the same (this) repository. So they have been put in separate folders to avoid name conflicts.
- Here is the reference guide for the commands.
- Here are more detailed instructions from the git v2 book.
These instructions assume that you are already in a git repository.
git clone --recurse-submodules <URL>
To clone a repository and all of it's submodules.
git submodule add [-b <branch>] [--name <name>] <URL> [<path>]
Adds a git repository to the current repository. Note that with the path it will create the subdirectory for you.
git mv <source dir> <destination dir>
Git support mv as in linux. You can therefore move submodule directories if included into the wrong path.
git submodule update --remote
Update all submodules.
cd <submodule>
git pull <branch>
Update individual submodules.
Sometimes setting up the environment for C/C++ can be annoying, here are the .vscode file settings I used. After following these steps to install a compiler.
{
"configurations": [
{
"name": "C/C++: g++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "C:\\msys64\\ucrt64\\bin",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\ucrt64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
],
"version": "2.0.0"
}
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe build active file",
"command": "C:\\msys64\\ucrt64\\bin\\g++.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "C:\\msys64\\ucrt64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "Task generated by Debugger."
}
],
"version": "2.0.0"
}