Using this example:
- Assume you have a foam vault repo named: repo-of-notes
- You have a Quartzrepo, forked from https://github.com/jackyzha0/quartz.
- You want to add repo-of-notesas a submodule toQuartzto thecontentfolder so that quartz site can render your notes.
Add submodule
In your Quartz repo, run:
git submodule add https://github.com/username/repo-of-notes.git contentNote that, content/ folder probably is already in your git index,
so this command may fail with error. For this example of quartz, just
delete the content/ folder and run the command again.
This command should create a .gitmodules file in your Quartz repo which
specifies the git-submodule information. It should look like:
[submodule "content"]
    path = content
    url = git@github.com:qining/notes.git
	# You can add this to track a specific branch
	# branch = main
Then you need to:
# Add both the .gitmodules file and the 'content' folder to your index.
git add .gitmodules content
git commit -m "Add submodule as content"
# Just push as normal
git pushAlways commit pined implicitly
git-submodule will always have the submodule pined to the specific commit of the submodule when you add it.
git submodule update --init --recursivewon’t update the submodule to the latest commit, neither willgit clone --recursive
Update submodule commit
Update all submodules to the latest commit:
git submodule update --remoteNote
Remove submodule
deinit first:
# git submodule deinit -f path/to/submodule
git submodule deinit -f contentrm files next:
# git rm -f path/to/submodule
git rm -f contentNote
If you want to keep the files in the work tree:
git rm --cached path/to/submodule