-
-
Notifications
You must be signed in to change notification settings - Fork 44
Adding git based source material as a git submodule
If you are creating a deck and your cards are based on source material that is version controlled with git, you can add the source material as a submodule pegged at a specific commit. If you're not interested in older commits, you can even set it up to not fetch the whole history. As an example with the Anki source code) (I would have chosen the Anki manual as an example here, but it doesn't utilize git tags and I want to demonstrate cloning at a specific tag):
-
Change directories into your deck project directory:
cd ~/anki-collab-decks/anki
-
Add the source material git repo as a submodule.
--depth 1
creates a shallow clone (most recent commit):git submodule add --depth 1 https://github.com/ankitects/anki
-
change directories in the new source material directory:
cd anki
4a. fetch only commit that you want by tag name (-n
tells it to get no tags instead of all of them, this flag gets overwritten by the refspec):
git fetch --depth 1 -n origin 2.1.61:refs/tags/2.1.61
4b. OR if the source material repo doesn't use tags, you can reference a commit by the hash (must be the full hash at the time of this writing):
git fetch --depth 1 -n origin 55f4ccdcbedcbc6be23c6b309db52e87766d63cb
-
checkout the submodule at the commit:
git checkout 2.1.61
orgit checkout 55f4ccdcbedcbc6be23c6b309db52e87766d63cb
-
go to your deck repo:
cd ..
-
commit the source material submodule to your deck repo
git add . && git commit
Your deck repo will now also contain your version-controlled source material